Last active
May 15, 2022 05:35
-
-
Save KorigamiK/1e74bf5bb84dc24a3f280434ea8a136a to your computer and use it in GitHub Desktop.
Snahp.it User Scripts
This file contains 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
// ==UserScript== | |
// @name snahp.eu Forum Sort Topics by Filesize | |
// @grant none | |
// @match *://fora.snahp.eu/* | |
// ==/UserScript== | |
function sortAllLists(){ | |
Array.from(document.getElementsByClassName('topics')).forEach(sortByFileSize); | |
return; | |
} | |
function sortByFileSize(list){ | |
Array.from(list.getElementsByClassName('row')).sort(compareSize).forEach(li => list.appendChild(li)); | |
return; | |
} | |
function compareSize(a,b){ | |
var regex = /\d+(\.\d+)? *(kb|mb|gb|tb)/i; | |
if (regex.exec(a.getElementsByClassName('topictitle')[0].innerHTML) !== null){ | |
var sizeA = regex.exec(a.getElementsByClassName('topictitle')[0].innerHTML)[0]; | |
sizeA = sizeA.replace(/ *kb/i, ' * 1000'); | |
sizeA = sizeA.replace(/ *mb/i, ' * 1000000'); | |
sizeA = sizeA.replace(/ *gb/i, ' * 1000000000'); | |
sizeA = sizeA.replace(/ *tb/i, ' * 1000000000000'); | |
sizeA = eval(sizeA); | |
} else | |
sizeA = Number.MAX_SAFE_INTEGER; | |
if (regex.exec(b.getElementsByClassName('topictitle')[0].innerHTML) !== null){ | |
var sizeB = regex.exec(b.getElementsByClassName('topictitle')[0].innerHTML)[0]; | |
sizeB = sizeB.replace(/ *kb/i, ' * 1000'); | |
sizeB = sizeB.replace(/ *mb/i, ' * 1000000'); | |
sizeB = sizeB.replace(/ *gb/i, ' * 1000000000'); | |
sizeB = sizeB.replace(/ *tb/i, ' * 1000000000000'); | |
sizeB = eval(sizeB); | |
} else | |
sizeB = Number.MAX_SAFE_INTEGER; | |
return sizeA - sizeB; | |
} | |
if (document.getElementsByClassName('topics').length > 0){ | |
var element = document.getElementsByClassName("bar-top"); | |
for (var i = 0; i < element.length; i++) { | |
element[i].insertAdjacentHTML("beforeend", "<button class='button' id='SortAllTopics" + i + "'>Filesize Sort</button>"); | |
document.getElementById("SortAllTopics" + i).onclick = sortAllLists; | |
} | |
} |
This file contains 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
// ==UserScript== | |
// @name Snahp.eu urls decoder | |
// @match https://*.snahp.*/viewtopic.php* | |
// @icon https://cdn-icons-png.flaticon.com/512/2362/2362269.png | |
// @description This script detects base64 encoded urls present in snahp pages and decodes them automatically without having to go to other websites :) | |
// ==/UserScript== | |
console.log("Script engaged"); | |
function copy_text(e) { | |
Clipboard.copy(e.target.innerText); | |
} | |
document.querySelectorAll("code").forEach((e) => { | |
try { | |
e.innerText = atob(e.innerText); | |
} catch (error) {} | |
}); | |
document.querySelectorAll("dd").forEach((e) => { | |
try { | |
e.innerText = atob(e.innerText); | |
e.onclick = copy_text; | |
e.style.cursor = "pointer"; | |
} catch (error) {} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment