Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.sleazyfork.org/scripts/476583/1259171/commonlib.js
// ==UserScript==
// @name commonlib
// @namespace websiteEnhancement
// @author jimmly
// @version 2023.9.24
// @description 增加页面顶部底部按钮和一键下种按钮
// @create 2023-9-21
// @include *
// @grant GM_getValue
// @grant GM_setValue
// @grant GM.getValue
// @grant GM.setValue
// @require https://openuserjs.org/src/libs/sizzle/GM_config.min.js
// @license MIT
// @run-at document-idle
// ==/UserScript==
function withJQuery(callback, safe) {
if (typeof jQuery == "undefined") {
let script = document.createElement("script")
script.type = "text/javascript"
script.src = "https://code.jquery.com/jquery-3.6.1.min.js"
if (safe) {
let cb = document.createElement("script")
cb.type = "text/javascript"
cb.textContent = "jQuery.noConflict();(" + callback.toString() + ")(jQuery, window);"
script.addEventListener("load", function () {
document.head.appendChild(cb)
})
} else {
let dollar = undefined
if (typeof $ != "undefined") dollar = $
script.addEventListener("load", function () {
jQuery.noConflict()
$ = dollar
callback(jQuery, window)
})
}
document.head.appendChild(script)
} else {
setTimeout(function () {
//Firefox supports
callback(jQuery, typeof unsafeWindow === "undefined" ? window : unsafeWindow)
}, 30)
}
}
//addStyle
function addStyle(css) {
var s = document.createElement('style');
s.appendChild(document.createTextNode(css));
document.getElementsByTagName('head')[0].appendChild(s);
}
//createSuperLabel 创建超链接,不会被拦截
function createSuperLabel(url, id, download) {
if (!id)
id = url;
// 防止反复添加
if (!document.getElementById(id) && !localStorage[id]) {
let tmpLink = document.createElement("a");
localStorage[id] = true
if (download)
tmpLink.download = download;
tmpLink.setAttribute("href", url);
tmpLink.setAttribute("target", "_blank");
tmpLink.setAttribute("id", id);
document.body.appendChild(tmpLink);
tmpLink.click();
return true
}
return false;
}
function unique(arr) {
let obj = {};
return arr.filter(function (item, index, arr) {
return obj.hasOwnProperty(typeof item + item) ? false : (obj[typeof item + item] = true)
})
}
///ignore \r \t \n space and caseinsitive
function a_Contains_b(a, b) {
if (!!a && !!b && a.replace(/(\r\n|\n|\r|\t| )/gm, "").toLowerCase().indexOf(b.replace(/(\r\n|\n|\r|\t| )/gm, "").toLowerCase()) > -1) {
return true;
}
return false;
}
function autoFind(funcIsRun, cmgId, selector, funcText) {
GM_config.init({
id: `GM_config_${cmgId}`,
title: 'javdb Configurable Options Script',
fields: {
'asdf': {
'label': 'Search keys',
'type': 'textarea',
'rows': 30,
'cols': 50,
'default': '萝莉;奴隶;奴隸;调教;調教;拘束;軟體;软体;痙;攣;拘;束;固定;sm;白虎,捆绑,捆綁;束縛;束缚,母狗;性奴;緊縛;拷問;拷問;萝莉;奴隶;奴隸;调教;調教;拘束;軟體;软体;痙;攣;拘;束;固定;sm;白虎,捆绑,捆綁;束縛;束缚,母狗;軟派;緊縛;萝莉;奴隶;奴隸;调教;調教;拘束;軟體;软体;痙;攣;拘;束;固定;sm;白虎,捆绑,捆綁;束縛;束缚,母狗;無毛;一线天;18岁;19岁;20岁;一字马;圈养;调J;实录;母G; 阴环;乳环'
},
},
'events':
{
'open': function () {
let vals = unique(this.get('asdf').split(/;|;|,|,/gi)).join(';')
this.set('asdf', vals)
},
'save': function () {
let vals = unique(this.get('asdf').split(/;|;|,|,/gi)).join(';')
this.set('asdf', vals)
}
}
})
//$('item a').removeAttr('style')
if (funcIsRun())
new Promise((resolve, reject) => resolve(GM_config.get('asdf')))
.then(conf => {
console.log('config value of keys', conf)
return conf.split(/;|;|,|,/i)
})
.then(keys => {
$(selector).each((i, element) => {
let el = $(element)
$.each(keys, (inex, key) => {
if (a_Contains_b(funcText(el), key)) {
console.log(key, createSuperLabel(el.prop('href')), el.prop('href'))
return false;
}
})
});
})
}