油猴资源安装器(新版适用)
哈哈 · v1.0.1 · 内容脚本 · 75 次安装
简介
无脑快速安装油猴到脚本狗,如果导入失败,可以直接全复制代码,在脚本狗新建文本编程项目,全部覆盖粘贴即可,脚本猫资源:https://scriptcat.org/zh-CN/search ,油叉资源:https://greasyfork.org/zh-CN/scripts
匹配网址
https://scriptcat.org/*https://greasyfork.org/*https://gf.qytechs.cn/*
脚本源码
setTimeout(() => {
if (location.hostname == 'greasyfork.org') {
initScriptFork()
} else if (location.hostname == 'scriptcat.org') {
initScriptCat()
}
}, 300)
function initScriptCat() {
const catLinks = document.querySelectorAll("a[href*='user.js']");
if (!catLinks) {
return
}
catLinks.forEach(catLink => {
catLink.textContent = '安装到脚本狗';
catLink.style.backgroundColor = '#c7811e';
catLink.onclick = (e) => {
e.preventDefault();
window.postMessage({ type: 'installDogScript', data: encodeURIComponent(catLink.href) }, '*')
}
})
}
function initScriptFork() {
const btnGroup = document.querySelector('#install-area');
if (!btnGroup) {
return
}
const catLink = btnGroup.querySelector('.install-link');
const btn = document.createElement('a');
btn.href = 'javascript:void(0)';
btn.textContent = '安装到脚本狗';
btn.className = catLink.className;
btn.style.backgroundColor = '#c7811e';
btn.onclick = () => {
window.postMessage({ type: 'installDogScript', data: encodeURIComponent(catLink.href) }, '*')
}
btnGroup.insertBefore(btn, catLink);
}