您的位置:首页 > 理论基础 > 计算机网络

把google搜索结果的缓存链接变成https的gs脚本

2010-05-18 15:46 561 查看
借用了Google click-tracking disabler的代码,对原作者表示感谢。
// ==UserScript==
// @name			ghttpswebcache
// @namespace		wanderxjtu@twitter
// @description		把google搜索结果的缓存链接变成https
// @include	 http://www.google.com/search* // @include	 http://www.google.com.hk/search* // ==/UserScript==
// A test for whether or not an object is a DOM node that can contain other DOM nodes
var domlist = document.body.childNodes.constructor;
function fertile(o) { return (o.childNodes || false) && (o.constructor == domlist); }

// A simple string test we'll be using
if (String.prototype.beginsWith) {
console.warn('googleclicktrackingdisab.user.js warning: String.prototype.beginsWith() has already been defined');
} else {
String.prototype.beginsWith = function(s) {return this.slice(0, s.length) == s; }
}

Array.prototype.forEach.call(document.getElementsByTagName('a'), function(el) {
var s = el.getAttribute('href');
if (('string' == typeof s) && (s.beginsWith('http://webcache.google')))
el.setAttribute('href','https:'+s.slice(5,s.length));
});
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: