Library to hold common prototype extensions for your Furaffinity Script
Verzia zo dňa
Tento skript by nemal byť nainštalovaný priamo. Je to knižnica pre ďalšie skripty, ktorú by mali používať cez meta príkaz // @require https://update.greatest.deepsurf.us/scripts/525666/1759611/Furaffinity-Prototype-Extensions.js
// ==UserScript==
// @name Furaffinity-Prototype-Extensions
// @namespace Violentmonkey Scripts
// @grant GM_info
// @version 1.0.2
// @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://greatest.deepsurf.us/scripts/525666-furaffinity-prototype-extensions
// @supportURL https://greatest.deepsurf.us/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;
};
})();