Resume Bookmark

Visit bookmark page with the last tag filter selected.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Resume Bookmark
// @namespace   1330126-edexal
// @match       *://f95zone.to/account/bookmarks*
// @match       *://f95zone.to/*
// @grant       GM.setValue
// @grant       GM.getValues
// @icon        https://external-content.duckduckgo.com/ip3/f95zone.to.ico
// @license     Unlicense
// @version     1.0.0
// @author      Edexal
// @description Visit bookmark page with the last tag filter selected.
// @homepageURL https://sleazyfork.org/en/scripts/571484-resume-bookmark
// @supportURL  https://github.com/Edexaal/scripts/issues
// ==/UserScript==
(async () => {
  function addBtnEvent() {
    const button = document.querySelector('form[action*=bookmarks] span.menu-footer-controls button');
    button.addEventListener('click', async () => {
      const textBoxEl = document.querySelector("form[action*=bookmarks] li.select2-selection__choice");
      await GM.setValue("label", textBoxEl ? textBoxEl.title : null);
    });
  }
  function addTagRemoveBtnEvent(cssSelector) {
    const button = document.querySelector(cssSelector);
    if (!button) return;
    button.addEventListener('click', async () => {
      await GM.setValue("label", null);
    });
  }

  async function run() {
    if (location.href.includes("account/bookmarks")) {
      addBtnEvent();
      addTagRemoveBtnEvent("div.filterBar ul.filterBar-filters a.filterBar-filterToggle");
      const storage = await GM.getValues({was_bookmark: false, label: null});
      if (storage.was_bookmark) {
        return;
      }
      await GM.setValue("was_bookmark", true);
      if (storage.label) {
        location.replace(location.search === "" ? `${location.href}?label=${storage.label}` : `${location.href}&label=${storage.label}`);
      }
    } else {
      await GM.setValue("was_bookmark", false);
    }
  }

  await run();
})()