Skip to content

Instantly share code, notes, and snippets.

@akku1139
Last active December 12, 2023 05:22
Show Gist options
  • Select an option

  • Save akku1139/24a6bcf459bd1b53a0803ed76a0906ed to your computer and use it in GitHub Desktop.

Select an option

Save akku1139/24a6bcf459bd1b53a0803ed76a0906ed to your computer and use it in GitHub Desktop.
新しいタブでリンクを開くことを阻止するユーザースクリプト
// ==UserScript==
// @name 絶対新しいタブで開かない
// @namespace Violentmonkey Scripts
// @match *://*/*
// @grant none
// @version 1.0
// @author -
// @description 12/7/2023, 10:44:38 PM
// ==/UserScript==
window.open = function(url, target="", windowFeatures="") {
location.href = url;
}
Array.from(document.getElementsByTagName("a")).forEach(e => {
if(/_blank|_new|blank|new/.test(e.getAttribute("target"))) {
e.removeAttribute("target");
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment