Skip to content

Instantly share code, notes, and snippets.

Created April 3, 2018 04:30
What would you like to do?
Tampermonkey Userscript - Automatically Close Tab Based on Page Text
// ==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 ="","_self");
Copy link

dlepold commented Mar 9, 2022

I love this one. Thank you! I'll add a setTimeout() to it (line 12)
setTimeout(function(){ win.close(); },2000);

Copy link

good shit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment