快照链接

把谷歌快照的链接全部转换成谷歌快照

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        快照链接
// @namespace   lovearia.me
// @description 把谷歌快照的链接全部转换成谷歌快照
// @include     http://webcache.googleusercontent.com/search?*q=cache:*
// @version     3.1
// @grant       none
// ==/UserScript==
var foreach = function foreach(list, func) {
  return Array.prototype.forEach.call(list, func);
};
var translate = function translate(node_list) {
  foreach(node_list, function (node) {
    if (!!node.href) {
      node.href = 'http://webcache.googleusercontent.com/search?q=cache:' + escape(node.href);
    }
  });
};
var check = function check(node) {
  return node.getAttribute('style') === 'position:relative;';
};
var timer = setInterval(function () {
  if (document.body.childNodesCount < 3) return;
  foreach(document.body.childNodes, function (node) {
    if (check(node)) {
      translate(node.getElementsByTagName('a'));
      clearInterval(timer);
    };
  });
}, 100);