Skip to content

Instantly share code, notes, and snippets.

@Orangestar12
Created January 14, 2024 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Orangestar12/e730e63aa859fac9244882fc4a3a2d46 to your computer and use it in GitHub Desktop.
Save Orangestar12/e730e63aa859fac9244882fc4a3a2d46 to your computer and use it in GitHub Desktop.
Accessible TVTropes Title Text
// ==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