Untarget _blank

Murderise target="_blank"

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

Advertisement:

// ==UserScript==
// @name        Untarget _blank
// @namespace   https://git.sr.ht/~remph
// @include     *
// @grant       none
// @version     0.2
// @author      Remph
// @description Murderise target="_blank"
// @license     GPL-3.0-or-later
// ==/UserScript==

function unblank(root) {
	root.querySelectorAll(
		'a[target="_blank"], base[target="_blank"]' // form[target="_blank"]
	).forEach((a) => a.setAttribute('target', '_self')); // could also removeAttribute
}

(function() {
	unblank(document.body); // run straight away to unblank static content
	// hang around in the background to keep interfering
	new MutationObserver(
		(muts) => muts.forEach((mut) => unblank(mut.target))
	).observe(document.body, {
		subtree: true, childList: true, attributes: true
	});
})();