Created
August 9, 2008 03:28
-
-
Save anonymous/4648 to your computer and use it in GitHub Desktop.
undefined
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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