-
-
Save thefloodshark/53e4497d6c8b1daefb24f5949ecae55e to your computer and use it in GitHub Desktop.
Tampermonkey Userscript - Automatically Close Tab Based on Page Text
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 Autoclose Tab | |
// @namespace Autoclose Tab | |
// @include * | |
// ==/UserScript== | |
// separate words or phrases with a comma | |
var blacklist = ["cactus", "finances", "put other text here"], | |
re = new RegExp(blacklist.join('|'), "i"); | |
if (re.test(document.body.textContent)) { | |
var win = window.open("","_self"); | |
win.close(); | |
} |
what about the Scripts may only close windows that were opened by a script.
warning? was this security patch introduced later? cuz rn neither var win = window.open("","_self"); win.close()
nor window.close()
works
you need // @grant window.close
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good shit