Sleazy Fork is available in English.

F95 Latest Update Saver

Save your current Latest Update Page configurations & load it when you need it!

// ==UserScript==
// @name        F95 Latest Update Saver
// @namespace   1330126-edexal
// @match       *://f95zone.to/sam/latest_alpha/*
// @grant       GM.setValue
// @grant       GM.getValue
// @icon        https://external-content.duckduckgo.com/ip3/f95zone.to.ico
// @license     Unlicense
// @version     1.1
// @author      Edexal
// @description Save your current Latest Update Page configurations & load it when you need it!
// ==/UserScript==
(async function () {
  //Apply custom styles in a style tag
    function applyCSS(css) {
        let styleEl = document.querySelector("style");
        if (styleEl === null) {
            styleEl = document.createElement('style');
        }
        styleEl.appendChild(document.createTextNode(css));
        document.head.appendChild(styleEl);
    }
  function getStyles(){
    return `
    @keyframes notice {
      0% {opacity:0;}
      30% {opacity:1;}
      60% {opacity:1;}
      100% {opacity:0;};
    }
      #save-notice {
        position: fixed;
        z-index: 8;
        top: 33%;
        left: 40vw;
        background-color:#2d2d2d;
        color: yellow;
        border-radius: 10px;
        border: 2pt outset #6ce65b;
        box-shadow: -1px 0px 5px #cece92;
        width: 120px;
        padding-top:15px;
        padding-bottom:15px;
        font-size: 18px;
        font-weight:bold;
        text-align:center;
        opacity: 0;
      }
      .save-anim {
        animation: 3s notice ease-in-out;
      }
      .save-bg {
        opacity: 0.6;
      }

      a.fa-hdd::before, a.fa-save::before {
	      color: #f0c315 !important;
      }
      div#filter-block_settings h4 {
        color: #fc9b46 !important;
      }

    `;
  }
  function addSaveNotice(){
    let notice = document.createElement('div');
    notice.id = 'save-notice';
    let txtNode = document.createTextNode('Saved!');
    notice.append(txtNode);
    document.body.append(notice);

    applyCSS(getStyles());
  }
  function createSection(){
    let section = document.createElement('div');
    section.id = 'filter-block_settings';
    section.classList.add('filter-block');
    return section;
  }
  function createHeader(){
    let h = document.createElement('h4');
    h.classList.add('filter-block_title');
    let txtNode = document.createTextNode('Settings');
    h.append(txtNode);
    return h;
  }
  function createSectWrap(){
    let outerContainer = document.createElement('div');
    outerContainer.classList.add('filter-block_content', 'filter-block_h');
    return outerContainer;
  }

  //Utility function for creating buttons
  function createBtn(name,classNames,eventFunc){
    let innerContainer = document.createElement('div');
    innerContainer.id = `btn-settings_${name}`;
    innerContainer.classList.add('filter-block_button-wrap');

    let a = document.createElement('a');
    a.href = "#";
    a.setAttribute('data-settings',name);
    a.classList.add('filter-block_button', ...classNames);
    a.addEventListener('click',eventFunc);

    let label = document.createElement('div');
    label.classList.add('filter-block_button-label');
    let labelTxtNode = document.createTextNode(`${name[0].toUpperCase()}${name.substring(1)}`);
    label.append(labelTxtNode);


    innerContainer.append(a,label);
    return innerContainer;
  }

  function saveEvent(e){
    e.preventDefault();
    GM.setValue('url',location.href);
    let saveNotice = document.querySelector('#save-notice');
    let saveNoticeBG = document.querySelector('#top');
    if (!!!saveNotice.classList.contains('save-anim')){
      saveNotice.classList.add('save-anim');
      saveNoticeBG.classList.add('save-bg');
      setTimeout(()=>{
        saveNotice.classList.remove('save-anim');
        saveNoticeBG.classList.remove('save-bg');
      },3000)
    }
  }

  async function loadAsyncEvent(e){
    e.preventDefault();
    try {
      let url = await GM.getValue('url');
      location.href = url;
    }catch(err){
      console.error(err);
    }
  }
  function createSaveBtn(){
    return createBtn('save', ['fas','fa-save'], saveEvent);
  }
  function createLoadBtn(){
    return createBtn('load',['fas', 'fa-hdd'], loadAsyncEvent);
  }

  function getSettingsSect(){
    let settingsSect = createSection();
    let header = createHeader();
    let contentWrap = createSectWrap();
    let saveBtn = createSaveBtn();
    let loadBtn = createLoadBtn();
    contentWrap.append(loadBtn,saveBtn);
    settingsSect.append(header,contentWrap);

    return settingsSect;
  }

  function addSettingsSect(){
    let drawerEl = document.querySelector('.content-block_filter');
    let titleEl = document.querySelector('.content-block_filter-title');
    titleEl.after(getSettingsSect());

    addSaveNotice();
  }

  addSettingsSect();

})().catch(err => console.error(err));