Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2008 03:28
Show Gist options
  • Save anonymous/4648 to your computer and use it in GitHub Desktop.
Save anonymous/4648 to your computer and use it in GitHub Desktop.
undefined
function pelotto(context){
var a = $x("descendant-or-self::pre", context);
for (var i=0 ; i<a.length ; ++i) {
var s = a[i].textContent;
if ( !/^\s*\/\/ ==UserScript==/.test(s) ) continue;
var div = document.createElement('div');
div.style.marginBottom = "1em";
var l = document.createElement('a');
l.href = "data:text/html;charset=utf-8," + encodeURI(s) + "//.user.js";
l.setAttribute("style", "border: 1px solid #666; text-decoration:none; padding: 3px 6px;font-family: Arial; font-size: 10px; background: white; color: black;");
l.setAttribute("onmousedown", "this.firstChild.style.left = '1px'; this.firstChild.style.top = '1px'");
l.setAttribute("onmouseup", "this.firstChild.style.left = '0px'; this.firstChild.style.top = '0px'");
l.innerHTML =
'<span style="position: relative; left: 0px; top: 0px;">' +
//'<img src="data:image/gif," width=10 height=8> ' +
'<span style="font-size: 1.3em; padding-right: 5px; color: #2c2;">»</span>' +
'<span style="font-weight: bold;">Install this script</span></span>';
div.appendChild(l);
a[i].insertBefore(div, a[i].firstChild);
}
}
function $x(exp, context) {
var results = arguments.callee.results || null;
results = document.evaluate(
exp, context || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, results);
var arr = [];
for (var i = 0, l = results.snapshotLength; i < l; i++) {
arr[i] = results.snapshotItem(i);
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment