Greasy Fork is available in English.

Furaffinity-Prototype-Extensions

Library to hold common prototype extensions for your Furaffinity Script

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.org/scripts/525666/1760940/Furaffinity-Prototype-Extensions.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Furaffinity-Prototype-Extensions
// @namespace   Violentmonkey Scripts
// @grant       GM_info
// @version     1.0.3
// @author      Midori Dragon
// @description Library to hold common prototype extensions for your Furaffinity Script
// @icon        https://www.furaffinity.net/themes/beta/img/banners/fa_logo.png
// @license     MIT
// @homepageURL https://greasyfork.org/scripts/525666-furaffinity-prototype-extensions
// @supportURL  https://greasyfork.org/scripts/525666-furaffinity-prototype-extensions/feedback
// ==/UserScript==
// jshint esversion: 11
(function () {
    'use strict';

    Node.prototype.insertBeforeThis = function (newNode) {
        this.parentNode?.insertBefore(newNode, this);
    };
    Node.prototype.insertAfterThis = function (newNode) {
        this.parentNode?.insertBefore(newNode, this.nextSibling);
    };
    Node.prototype.getIndexOfThis = function () {
        if (this.parentNode == null) {
            return -1;
        }
        const childrenArray = Array.from(this.parentNode.children);
        return childrenArray.indexOf(this);
    };
    Node.prototype.readdToDom = function () {
        const clone = this.cloneNode(false);
        this.parentNode?.replaceChild(clone, this);
        return clone;
    };

    String.prototype.trimEnd = function (toTrim) {
        if (toTrim == null) {
            return '';
        }
        if (toTrim === '' || this === '') {
            return this.toString();
        }
        let result = this.toString();
        while (result.endsWith(toTrim)) {
            result = result.slice(0, -toTrim.length);
        }
        return result;
    };
    String.prototype.trimStart = function (toTrim) {
        if (toTrim == null) {
            return '';
        }
        if (toTrim === '' || this === '') {
            return this.toString();
        }
        let result = this.toString();
        while (result.startsWith(toTrim)) {
            result = result.slice(toTrim.length);
        }
        return result;
    };

})();