Userscripts

Userscripts are snippets of JavaScript that can be used client-side to modify the browsing experience.

  • [tablesorter][1]
  • [Show HTML Comments][2]
  • [Show Comments](javascript:(function(){function f(a,fn){var i,l;for(i=0,l=a.length;i<l;i++)fn(a[i]);}var ca = [];function fc(p){f(p.childNodes,function(n){if(n.nodeType===8){ca.push(n);}else{fc(n);}});}function esc(t){return t.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/'/g,''')};var D=document;fc(D);function mk(p,t,s, i){var e=D.createElement(t); e.style.cssText=s; p.appendChild(e); if(i)e.innerHTML=esc(i); return e};var x=mk(D.body,‘div’,‘position: fixed; top:0; left:0; height:100%;width:100%; background-color: #cccccc; z-index: 9999; opacity: 0.8; filter:alpha(opacity=80);');var y=mk(D.body, ‘div’, ‘position: fixed; top:3em; left: 50%; margin-left: -20em; width: 40em; z-index: 9999; font-size: 10pt; border: 1px solid black; padding: 10px; font-family: sans-serif; background-color: white; opacity: 1.00; filter:alpha(opacity=99);');mk(y,‘h1’,‘color: black; font-size: 12pt; font-weight: bold; margin-left: auto; margin-right: auto; font-decoration: underline; margin: 0; padding: 0;’, ‘HTML Comments’);mk(y,‘p’,‘color: black; font-size: 10pt;',ca.length + ' comment’ + (ca.length===1?'':’s’) + ' found on this page’);var w=mk(y, ‘div’, ‘overflow: auto; height: 200px’);f(ca,function(n){mk(w,‘p’,‘padding: 0; margin:0; margin-bottom: 3px; margin-top: 3px; color: black;’, n.nodeValue);});var z=mk(y,‘button’, ‘display: block; color: black; width: 3em; border: 1px solid black; padding: 5px; margin-top: 10px; margin-left: auto; margin-right: auto; cursor: pointer;’, ‘OK’);z.onclick=function(){D.body.removeChild(x);D.body.removeChild(y);};})())

[1]: <javascript:(function(){function a(a,b){for(var c=a.length,d=0;d<c;d++)b(a[d],d)}function b(a,b){for(var c in a)a.hasOwnProperty(c)&&b(a[c])}function d(c){function m(){d.sort(function(a,b){return a.getOriginalIndex()-b.getOriginalIndex()}),v()}function n(a,b){if(a<j){var c=b?1:-1;d.sort(function(b,d){var e=b.getCellValue(a);e=e?e.toLowerCase():e;var f=d.getCellValue(a);return f=f?f.toLowerCase():f,e?f?e>f?1c:e<f?-1c:0:1c:f?-1c:0})}v()}function o(a,b){function c(a){return parseFloat(a.replace(/,/g,'').replace(/[^0-9.+-]+/,' ‘))}if(a<j){var e=b?1:-1;d.sort(function(b,d){var f=c(b.getCellValue(a));if(isNaN(f))return 1/0;var g=c(d.getCellValue(a));return isNaN(g)?-(1/0):(f-g)e})}v()}function p(a){function d(a){var b=a.childNodes;if(!b)return!1;for(var c,e=3,f=/^\s+|\s+$/,g=0,h=b.length;g<h;g++)if(c=b[g],c.nodeType===e){var i=c.nodeValue;if(i=i.replace(f,''),i.length>0)return!0}else if(d(c))return!0;return!1}var b=a.getElementsByTagName(‘TABLE’);if(b.length>0)return!1;var c=a.getElementsByTagName(‘TR’);return!(c.length<2)&&!!d(a)}function q(b,c){if(‘THEAD’===b.parentNode.tagName)return null;var d=b.getElementsByTagName(‘TD’);if(0===d.length)return null;var e={};e.getTr=function(){return b};var f=b.parentNode,g=[],h=0;return a(d,function(a,b){var c=+a.colSpan;(isNaN(c)||0===c)&&(c=1);for(var d=0;d<c;d++)g[h++]=b}),e.getCellCount=function(){return g.length},e.getCellValue=function(a){if(a>=g.length)return null;var b=g[a],c=d[b].innerHTML,e=/<[^<]>/g;return c=c.replace(e,'')},e.getOriginalIndex=function(){return c},e.removeFromParent=function(){f.removeChild(b)},e.attachToParent=function(){f.appendChild(b)},e}function r(a){l=a,b(k,function(a){var b=a===l;a.link.style.color=b?‘gray’:‘black’,a.link.style.cursor=b?'':‘pointer’}),h.style.display=a===k.NONE?‘none’:'',null!==e&&t(e,!1,!1)}function s(){var a=d[0].getTr();i=document.createElement(‘TR’),i.style.textAlign=‘center’,a.parentNode.insertBefore(i,a);var b=document.createElement(‘TD’);b.colSpan=j;var c=document.createElement(‘SPAN’),e=document.createElement(‘A’);e.style.paddingLeft=‘0.5em’,e.style.cursor=‘pointer’,e.innerHTML='%E2%87%95ABC’,e.title=‘Sort alphabetically’,e.onclick=function(a){r(k.ALPHA)},k.ALPHA.link=e;var f=document.createElement(‘A’);f.style.paddingLeft=‘0.5em’,f.style.cursor=‘pointer’,f.innerHTML='%E2%8E%8C',f.title=‘Undo sorting’,f.onclick=function(a){r(k.NONE),k.NONE.fn()},k.NONE.link=f;var l=document.createElement(‘A’);l.style.paddingLeft=‘0.5em’,l.style.cursor=‘pointer’,l.innerHTML='%E2%87%95123',l.title=‘Sort numerically’,l.onclick=function(a){r(k.NUM)},k.NUM.link=l,b.appendChild(c),b.appendChild(e),b.appendChild(l),b.appendChild(f),i.appendChild(b),h=document.createElement(‘TR’),a.parentNode.insertBefore(h,a);for(var m,n,o=0;o<j;o++)m=document.createElement(‘TD’),m.style.fontWeight=‘bold’,m.style.textAlign=‘center’,g.push(m),n=document.createElement(‘A’),m.appendChild(n),h.appendChild(m),u(o,!1,!1);r(k.NONE)}function t(a,b,c){null===e?u(a,b,c):a==e?null!=f&&(f&&b||!f&&c)||u(a,b,c):(u(e,!1,!1),u(a,b,c))}function u(a,b,c){for(var d=g[a];d.firstChild;)d.removeChild(d.firstChild);var h=document.createElement(‘SPAN’);h.innerHTML=b?'%E2%96%B2':'%E2%96%B3',h.style.cursor=‘pointer’,h.title=‘Sort Ascending’,h.onclick=function(b){t(a,!0,!1),e=a,f=!0,l.fn(a,!0)};var i=document.createElement(‘SPAN’);i.innerHTML=c?'%E2%96%BC':'%E2%96%BD',i.style.cursor=‘pointer’,i.title=‘Sort Descending’,i.onclick=function(b){t(a,!1,!0),e=a,f=!1,l.fn(a,!1)},d.appendChild(h),d.appendChild(i)}function v(){a(d,function(a){a.removeFromParent()}),a(d,function(a){a.attachToParent()})}if(!p(c))return null;var h,i,d=[],e=null,f=null,g=[],j=0,k={NONE:{text:‘none’,fn:m},ALPHA:{text:‘alpha’,fn:n},NUM:{text:‘num’,fn:o}},l=k.NONE;a(c.getElementsByTagName(‘TR’),function(a,b){var c=q(a,b);c&&(d.push(c),j=j<c.getCellCount()?c.getCellCount():j)}),s()}a(document.getElementsByTagName(‘TABLE’),function(a){d(a)})}());>

[2]: javascript:(function(){function process(tag){var i,l,els=document.getElementsByTagName(tag);for(i=0,l=els.length;i<l;i++){els[i].readOnly = null;els[i].disabled = null;}}process(‘input’);process(‘select’);process(‘textarea’);process(‘button’);})()

https://codebox.net/pages/bookmarklets

Related