// ==UserScript==
// @name 油猴助手
// @description 帮助坚持访问的网站是否有油猴插件
// @author 018(lyb018@gmail.com)
// @contributor Rhilip
// @connect *
// @grant GM_xmlhttpRequest
// @grant GM_setClipboard
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_listValues
// @grant GM_deleteValue
// @grant GM_registerMenuCommand
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @include *
// @version 0.1.1
// @icon https://greasyfork.org/packs/media/images/blacklogo16-5421a97c75656cecbe2befcec0778a96.png
// @run-at document-end
// @namespace http://018.ai
// @downloadURL none
// ==/UserScript==
// This Userscirpt can't run under Greasemonkey 4.x platform
if (typeof GM_xmlhttpRequest === 'undefined') {
alert('不支持Greasemonkey 4.x,请换用暴力猴或Tampermonkey')
return
}
;(function () {
'use strict';
$(document).ready(function () {
sniffer(location.host)
})
function sniffer(host) {
var url = 'https://greasyfork.org/zh-CN/scripts/by-site/' + host + '?filter_locale=0'
loadDoc(url, {url: url}, function(doc, responseDetail, meta) {
var list = doc.querySelector('#browse-script-list');
if (list) {
$('body').after('\
');
} else if(host.indexOf('.') > -1) {
sniffer(host.replace(/^[a-zA-z0-9\-_]*\./, ''))
}
}, function(responseDetail, meta) {
console.error(responseDetail)
});
}
// 对使用GM_xmlhttpRequest返回的html文本进行处理并返回DOM树
function page_parser(responseText) {
// 替换一些信息防止图片和页面脚本的加载,同时可能加快页面解析速度
responseText = responseText.replace(/s+src=/ig, ' data-src='); // 图片,部分外源脚本
responseText = responseText.replace(/