문제

I have never have done anything with Javascript before, after messing around trying to make a chrome userscript with tampermonkey I can't seem to get this action to through... The function works just fine, yet when going like this I keep getting a bad assignment or no error but the action won't through... This probably looks extremely ugly or bad, but any advice on how to get the replace to go through based on whether or not the text is 25-1

Thanks to anyone who can help.

function W01() 
{       
if (/another 25 seconds before attempting to search again/i.test (document.body.innerHTML) )
{
    document.body.innerHTML() = document.body.innerHTML.replace('Sorry, but you can only perform one search every 25 seconds. Please wait another 25 seconds before attempting to search again.', 'Press F5 or Reload the page now');
}
else if (/another 24 seconds before attempting to search again/i.test (document.body.innerHTML) )
{
    document.body.innerHTML() = document.body.innerHTML.replace('Sorry, but you can only perform one search every 25 seconds. Please wait another 24 seconds before attempting to search again.', 'Press F5 or Reload the page now');
}
    else if (/another 23 seconds before attempting to search again/i.test (document.body.innerHTML) )
    {
        document.body.innerHTML() = document.body.innerHTML.replace('Sorry, but you can only perform one search every 25 seconds. Please wait another 23 seconds before attempting to search again.', 'Press F5 or Reload the page now');
    }
}
도움이 되었습니까?

해결책

Remove the () in the innerHTML().

It should be:

document.body.innerHTML = "some HTML";

Note that it is not a function. It is a property.

For example do this:

document.body.innerHTML = document.body.innerHTML.replace('Sorry, but you can only perform one search every 25 seconds. Please wait another 23 seconds before attempting to search again.', 'Press F5 or Reload the page now');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top