21 lines
705 B
JavaScript
21 lines
705 B
JavaScript
|
window.addEventListener('load',e=>{
|
||
|
for(var c = document.getElementsByTagName("a"), a = 0;a < c.length;a++) {
|
||
|
var b = c[a];
|
||
|
((b.getAttribute("href") && b.hostname !== location.hostname) || (b.getAttribute("data-newtab")==true)) && (b.target = "_blank")
|
||
|
}
|
||
|
for(var c=document.getElementsByTagName("ol"), a=0; a<c.length;a++) {
|
||
|
var b = c[a];
|
||
|
if(b.getAttribute("data-bin")){
|
||
|
Array.from(b.children).forEach((child,i)=>{
|
||
|
if(!child.getAttribute("data-before"))
|
||
|
child.setAttribute("data-before", pad(i.toString(2), Math.log2(b.children.length)));
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
function pad(num, size) {
|
||
|
var s = "000000000" + num;
|
||
|
return s.substr(s.length-size);
|
||
|
}
|
||
|
|