Created
January 14, 2024 03:54
-
-
Save Orangestar12/e730e63aa859fac9244882fc4a3a2d46 to your computer and use it in GitHub Desktop.
Accessible TVTropes Title Text
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 Accessible Title Text - tvtropes.org | |
// @namespace Orangestar Scripts | |
// @match https://tvtropes.org/pmwiki/pmwiki.php/* | |
// @grant none | |
// @version 1.0 | |
// @author Orangestar | |
// @description 10/17/2023, 5:37:03 PM | |
// ==/UserScript== | |
let allLinks = Array.from(document.querySelectorAll('.twikilink')); // this isn't optimal but its easier than promises | |
function converter() { | |
let link = allLinks.pop(); | |
if (link.getAttribute('title')) { | |
link.title = link.title.replace('/Main/', '/').slice(link.title.indexOf('php/') + 4).replaceAll(/([A-Z])/g, ' $1').trim() | |
let compare = (link.title.slice(link.title.indexOf('/') + 2).trim() == link.textContent) | |
// console.log(link.title.slice(link.title.indexOf('/') + 2).trim(), link.textContent, compare) | |
if (compare) { | |
link.removeAttribute('title'); | |
} else { | |
link.title.replace('/ ', ' - ') | |
} | |
} | |
// console.log(link) | |
if (allLinks.length > 0) { | |
setTimeout(converter, 1) | |
} | |
} | |
setTimeout(converter, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment