关于Google搜索结果里的点击跟踪
2010-01-20 19:15 Kaedei 阅读(825) 评论(0) 编辑 收藏 举报经常用Google点com的同学可能发现,当点击结果时,不会直接跳转到目标网页,而是先经过google的中转,但是呢,由于我们强大的wall(突然想起长城宽带的英文是GreatWall broadband network,汗),没准会在网页跳转的半截抽一下风,于是我们就会看到一张白白的网页了……
详细信息及解决方案见此:
http://www.kenengba.com/post/1888.html
不过这个方法有个缺点——网页跳转功能是为了统计你的网络历史记录的:
如果只是屏蔽onmousedown事件的话就会使这个功能失效——毕竟是一个很好用的功能,就这么不能用了实在可惜。
于是乎我就想起了一个方法……在结果链接旁边添加一个“直接打开”的链接不就行了?平时点普通结果,如果遇到重定向就可以点击“直接打开”的链接应急。实验了一下,结果的风格几乎和Google原版一样。
如下图所示:
使用方法:
安装Firefox插件油猴子(GreaseMonkey),然后添加以下JS脚本即可:
(没学过JS,代码貌似很弱智勿笑)
JS文件
// ==UserScript==
// @name google_direct_link
// @namespace http://www.google.com
// @description 在google搜索结果页面增加直接链接地址
// @include http://www.google.com*
// @include http://www.google.cn/search?*
// ==/UserScript==
(function() {
var redirectLinks = document.evaluate(
"//a[@class='l']"
, document
, null
, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE
, null);
var link, marker, href;
if (typeof redirectLinks != 'undefined' && redirectLinks.snapshotLength > 0) {
for (var i = 0; i < redirectLinks.snapshotLength; i++) {
link = redirectLinks.snapshotItem(i);
//打开此注释可以把原来的结果也变成直接链接,不过会失去“网络历史纪录”的功能
//link.setAttribute('onmousedown','');
href = link.getAttribute('href');
marker = document.createElement_x('a');
marker.setAttribute('href', href);
marker.setAttribute('target', '_blank');
marker.textContent = '直接打开';
marker.style.font="12px arial,serif";
marker.style.color = "#77C";
link.parentNode.appendChild(marker);
link.parentNode.insertBefore(document.createTextNode(' - ') , marker);
}
}
})()
// @name google_direct_link
// @namespace http://www.google.com
// @description 在google搜索结果页面增加直接链接地址
// @include http://www.google.com*
// @include http://www.google.cn/search?*
// ==/UserScript==
(function() {
var redirectLinks = document.evaluate(
"//a[@class='l']"
, document
, null
, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE
, null);
var link, marker, href;
if (typeof redirectLinks != 'undefined' && redirectLinks.snapshotLength > 0) {
for (var i = 0; i < redirectLinks.snapshotLength; i++) {
link = redirectLinks.snapshotItem(i);
//打开此注释可以把原来的结果也变成直接链接,不过会失去“网络历史纪录”的功能
//link.setAttribute('onmousedown','');
href = link.getAttribute('href');
marker = document.createElement_x('a');
marker.setAttribute('href', href);
marker.setAttribute('target', '_blank');
marker.textContent = '直接打开';
marker.style.font="12px arial,serif";
marker.style.color = "#77C";
link.parentNode.appendChild(marker);
link.parentNode.insertBefore(document.createTextNode(' - ') , marker);
}
}
})()