Skip to content

Instantly share code, notes, and snippets.

@abeforgit
Last active January 6, 2023 19:03
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 abeforgit/34d2d02e0ba02949db2a6c6a2a5494d1 to your computer and use it in GitHub Desktop.
Save abeforgit/34d2d02e0ba02949db2a6c6a2a5494d1 to your computer and use it in GitHub Desktop.
// ==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