Following the answer here, I'm trying to check with if there are 2 strings on a page then perform the function.
The below works but once I change it to && which is the operator for AND it doesn't work? - Am I missing something? (This will be my first Greasemonkey script)
Here is my current code for the OR operator which works - I simply want it to be AND (so if both texts exists then perform function)
if (/(text1) || (text2)/i.test (document.body.innerHTML))
{
var input=document.createElement("input");
input.type="button";
input.value="Intuit SLI";
input.onclick = redirect;
input.setAttribute("style", "font-size:18px;position:absolute;top:120px;right:40px;");
document.body.appendChild(input);
function redirect()
{
var URLa = 'https://someurlhere';
var URL_FINALa = encodeURI(URLa);
window.open(URL_FINALa, '_blank');
}
}
answered with @JaromandaX 's suggestion.
if (/text1/.test(document.body.innerHTML) && /text2/.test(document.body.innerHTML))