I have this script which closes a tab if it finds a certain element on the page:
// ==UserScript==
// @name Name
// @namespace bbb
// @match https://example.com
// @include about:config
// @version 1
// @grant none
// ==/UserScript==
var intv = setInterval(function() {
if (/(container)|(mediumheight)/i.test (document.body.innerHTML) )
{
window.close()
}
}, 1000);
How can I make it close the page if it finds this:
<span id="some">0</span>
But it has to check for both the id (some) and for the number (0). Both must be on the page for the script to fire.
If it was just the id (some) I could do it, but I need both to be true for the script to fire.
Can anyone help? Thanks
<span id="some">0</span>
But it has to check for both the id (some) and for the number (0). Both must be on the page for the script to fire.
Here is an example of how you get check it:
const sp = document.querySelector('#some'); // find id (some)
if (sp && sp.textContent === '0') {
// run the function
}