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, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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;
    };

})();