-
-
Save JLChnToZ/0420b2b2d4a89f5f161108ccf39a6039 to your computer and use it in GitHub Desktop.
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 Fix plurk plinks | |
// @namespace https://plurk.moka-rin.moe/ | |
// @match https://www.plurk.com/* | |
// @grant none | |
// @version 1.0 | |
// @author Jeremy Lam "JLChnToZ" | |
// @description Temporary fix plinks | |
// ==/UserScript== | |
let delayHandle; | |
const urlMatcher = /^https?:\/\/(?:(?:www|m)\.)?plurk\.com\/(?:[sm]\/)?p\/([a-z0-9]+)\/?$/i; | |
const observer = new MutationObserver(() => { | |
if(!delayHandle) | |
delayHandle = setTimeout(fixLinks, 100); | |
}); | |
observer.observe(document.body, { | |
childList: true, | |
subtree: true, | |
}); | |
fixLinks(); | |
function fixLinks() { | |
delayHandle = undefined; | |
const exLinks = document.querySelectorAll('.text_holder a.ex_link.meta:not(.plink)'); | |
for(let i = 0; i < exLinks.length; i++) { | |
const exLink = exLinks[i]; | |
if(urlMatcher.test(exLink.href)) exLink.classList.add('plink'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment