Last active
May 27, 2024 04:28
-
-
Save GwyndolynMarchant/273b8060c2b293ead4b9865208816038 to your computer and use it in GitHub Desktop.
Adds a button to the qBittorrent WebUI toolbar which: chops up torrent names and bubbles and colours their tags
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 qBittorrent WebUI Name Tagger | |
// @namespace http://shadenexus.com/ | |
// @version 0.2 | |
// @description Adds a button to the toolbar which: chops up torrent names and bubbles and colours their tags | |
// @author Gwyndolyn Marchant | |
// @match http://qb.your.intranet/ | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function generateTags() { | |
for (let e of document.querySelectorAll("#torrentsTableDiv tr > td:nth-child(3)")) { | |
e.innerHTML = e.innerHTML.replace(/\[(.+?)\]/g, '<span class="square tag">$1</span>'); | |
e.innerHTML = e.innerHTML.replace(/\((.+?)\)/g, '<span class="round tag">$1</span>'); | |
console.log(e.innerHTML); | |
e.innerHTML = e.innerHTML.replace(/([Ss]\d{1,2})([Ee]\d{1,2})?/g, '<span class="season-episode"><span class="season">$1</span><span class="episode">$2</span></span>'); | |
} | |
} | |
function addStyle(rule) { | |
window.document.styleSheets[0].insertRule(rule, window.document.styleSheets[0].cssRules.length); | |
} | |
addStyle('.tag { border-radius: 4px; background: gray; color: white; padding: 0 2px; margin: 0 4px;}'); | |
addStyle('.square { background: OliveDrab; }'); | |
addStyle('.round { background: MediumSlateBlue; }'); | |
addStyle('.season-episode { background: lightgray; padding: 0 2px;}') | |
addStyle('.season { color: blue; }') | |
addStyle('.episode { color: red; }') | |
var eyeButton = document.createElement('button'); | |
eyeButton.innerText = "👁"; | |
eyeButton.addEventListener("click", generateTags); | |
document.getElementById("mochaToolbar").appendChild(eyeButton); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment