Greasy Fork is available in English.

Furaffinity-Custom-Pages

Helper Script to create Custom pages on Furaffinitiy

Този скрипт не може да бъде инсталиран директно. Това е библиотека за други скриптове и може да бъде използвана с мета-директива // @require https://update.greasyfork.org/scripts/476762/1318215/Furaffinity-Custom-Pages.js

// ==UserScript==
// @name        Furaffinity-Custom-Pages
// @namespace   Violentmonkey Scripts
// @grant       none
// @version     1.1.0
// @author      Midori Dragon
// @description Helper Script to create Custom pages on Furaffinitiy
// @icon        https://www.furaffinity.net/themes/beta/img/banners/fa_logo.png?v2
// @homepageURL https://greasyfork.org/de/scripts/476762-furaffinity-custom-pages
// @supportURL  https://greasyfork.org/de/scripts/476762-furaffinity-custom-pages/feedback
// @license     MIT
// ==/UserScript==

// jshint esversion: 8

(() => {
  class CustomPage {
    constructor(pageUrl, parameterName) {
      this.parameterName = parameterName;
      this.url = pageUrl;
	  this.onPageOpenHandler = null;
    }

	set onopen(action) {
	  this.onPageOpenHandler = action;
      this.checkPageOpened();
	}

    pageOpened(parameterValue, openedPage) {
	  if (this.onPageOpenHandler) {
		const customData = new CustomData();
		customData.parameterName = this.parameterName;
		customData.parameterValue = parameterValue;
		customData.document = openedPage;
		this.onPageOpenHandler(customData);
	  }
    }

    get isOpen() {
      const url = window.location.toString();
      if (this.pageUrl && !url.includes(this.pageUrl))
		return false;
      const parameter = extractParameterFromURL(url, this.parameterName);
      if (parameter && parameter.key == this.parameterName)
		return true;
      return false;
    }

    get parameterValue() {
      const url = window.location.toString();
      const parameter = extractParameterFromURL(url, this.parameterName);
      if (parameter)
		return parameter.value;
    }

    checkPageOpened() {
      if (this.isOpen)
		this.pageOpened(this.parameterValue, document);
    }
  }

  class CustomData {
    constructor() {
	  this.parameterName;
      this.parameterValue;
      this.document;
    }

    removeDocumentSiteContent() {
      const siteContent = this.document.getElementById("site-content");
      if (siteContent) siteContent.remove();
      return siteContent;
    }
  }

  function extractParameterFromURL(url, parameterName) {
    if (!url || !parameterName) return null;
    const parts = url.split("?");
    if (parts.length > 1) {
      const params = parts[1].split("&");
      for (const param of params) {
        const [key, value] = param.split("=");
        if (key === parameterName) return { key, value: decodeURIComponent(value) };
      }
    }
    return null;
  }

  window.CustomPage = CustomPage;
})();