Last active
January 6, 2023 19:03
-
-
Save abeforgit/34d2d02e0ba02949db2a6c6a2a5494d1 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 dont open spotify-links in new tab | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description fix the spotify integration in rateyourmusic by removing the target=_blank attrs from the spotify links. | |
// @author abeforgit | |
// @match https://*.rateyourmusic.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=rateyourmusic.com | |
// @run-at document-end | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const config = {childList: true, subtree: true}; | |
const cb = (mutationList) => { | |
if(mutationList.some(mutation => mutation.type === 'childList')) { | |
const links = document.querySelectorAll('a[title=Spotify][target=_blank]'); | |
links.forEach(node => node.removeAttribute("target")); | |
} | |
}; | |
const obs = new MutationObserver(cb); | |
obs.observe(document.body, config); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment