您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
最近访问dq.tieba.com老是出现 “您好,该页面正在维护中。” 于是就写了这个。为什么要在Google搜索页面替换呢?这是因为当你按dq.tieba.com时服务器就给你的浏览器发个HTTP 302重定向到维护页面,脚本都来不及执行
当前为
// ==UserScript== // @name Google谷歌搜索页面dq.tieba.com贴吧链接替换 dq.tieba.com to tieba.baidu.com for Google results // @name:zh-CN Google谷歌搜索页面dq.tieba.com贴吧链接替换 // @name:zh-TW Google谷歌搜索頁面dq.tieba.com貼吧鏈接替換 // @version 0.10 // @include *://www.google.* // @description 最近访问dq.tieba.com老是出现 “您好,该页面正在维护中。” 于是就写了这个。为什么要在Google搜索页面替换呢?这是因为当你按dq.tieba.com时服务器就给你的浏览器发个HTTP 302重定向到维护页面,脚本都来不及执行 // @description:zh-CN 最近访问dq.tieba.com老是出现 “您好,该页面正在维护中。” 于是就写了这个。为什么要在Google搜索页面替换呢?这是因为当你按dq.tieba.com时服务器就给你的浏览器发个HTTP 302重定向到维护页面,脚本都来不及执行 // @description:zh-TW 最近訪問dq.tieba.com老是出現 “您好,该页面正在维护中。” 於是就寫了這個。為什麼要在Google搜索頁面替換呢?這是因為當你按dq.tieba.com時服務器就給你的瀏覽器發個HTTP 302轉址到維護頁面,脚本都來不及執行 // @author Jiaxing Peng // @namespace bjxpen // @grant none // ==/UserScript== // ************************************************ // @match *://*/* to apply the script for all sites // ************************************************ (function() { "use strict"; var hostnamePatterns = [ '^c.tieba.baidu.*', '^tieba.baidu.*', '^dq.tieba.*', '^post.baidu.*', '^xingqu.baidu.*', '^www.tieba.*' ]; var replaceBy = "tieba.baidu.com"; var regExps = hostnamePatterns.map(function(p) { return new RegExp(p) }); var links = document.getElementsByTagName('a'); var redirectUrlRegExp = /^[^:]*:\/\/www.google.*\/url.*(?=url=)url=([^:]+:\/\/)([^&\/]+)(\/[^&]+)?.*$/ var scanResults = [].slice.call(links) .map(function(a) { return { aElm: a, matchedHostnamePatterns: regExps.filter(function(r) { return r.test(a.hostname) }), extractedUrlParts: redirectUrlRegExp.exec(a.href) } }) var redirectionResults = scanResults.filter(function(res) { return res.extractedUrlParts && res.extractedUrlParts[2] }) scanResults.filter(function(res) { return res.matchedHostnamePatterns.length > 0 }).forEach(function(res) { res.aElm.hostname = replaceBy res.aElm.protocol = 'https' }); redirectionResults.filter(function(res) { return regExps.filter(function(r) { return r.test(res.extractedUrlParts[2] ) }).length > 0 }).forEach(function (res) { res.extractedUrlParts[1] = 'https://' res.extractedUrlParts[2] = replaceBy }) redirectionResults.forEach(function (res) { res.aElm.href = ( res.extractedUrlParts[1] + res.extractedUrlParts.slice(2).map(decodeURIComponent).join("") ) }) })();