There are 3 previous versions of this script.
// ==UserScript==
// @name Google Cache Mapper
// @namespace http://www-ui.is.s.u-tokyo.ac.jp/~kobayash/
// @description Adds a navigation bar along the left border of the window that provides a quick way to find highlighted terms on a Google's cached page.
// @include http://*.*.*.*/search?q=cache:*
// ==/UserScript==
(function () {
const generalName = 'Google Cache Mapper';
const containerID = (generalName + new Date()).replace(/\W/g, '');
GM_addStyle('div#' + containerID + ' { position: fixed !important; left: 0 !important; top: 0 !important; width: 16px !important; height: 100% !important; background: transparent !important; border: 1px dotted silver !important; margin: 0 !important; padding: 0 !important; z-index: 65535 !important; -moz-border-radius: 0 !important; -moz-box-sizing: content-box !important; } div#' + containerID + ' > div { position: absolute !important; right: 0 !important; width: 100% !important; height: 8px !important; margin: 0 !important; padding: 0 !important; cursor: pointer !important; opacity: 0.5 !important; } div#' + containerID + ' > div:hover { background-color: red !important; opacity: 1.0 !important; z-index: 1 !important; }');
const panel = document.body.appendChild(document.createElement('DIV'));
panel.id = containerID;
panel.title = generalName;
const elements = document.evaluate('/descendant::B[starts-with(string(@style), "color: black; background-color: rgb(")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
// the next 2 definitions maybe unnecessary because cached pages are always in 'BackCompat' mode.
const offsetNode = document.compatMode == 'BackCompat' ? document.documentElement : document.body;
const scrollNode = document.compatMode == 'BackCompat' ? document.body : document.documentElement;
for (var i = 0; i < elements.snapshotLength; ++i) {
(function (o) {
var a = panel.appendChild(document.createElement('DIV'));
var s = a.style;
var d = (function (o, d) {
return o == null ? d : arguments.callee(o.offsetParent, d + o.offsetTop);
})(o, 0);
s.backgroundColor = o.style.backgroundColor;
s.bottom = (1 - d / offsetNode.clientHeight) * 100 + '%';
a.title = o.textContent + ' - ' + o.parentNode.textContent;
a.addEventListener('click', function(e) {
scrollNode.scrollTop = d - (panel.offsetHeight - o.offsetHeight) / 2;
}, false);
})(elements.snapshotItem(i));
}
})()
