我以前从来没有用 Javascript 做过任何事情,在试图用 tampermonkey 制作一个 chrome 用户脚本之后我似乎无法完成这个 Action ......这个功能工作得很好,但是当我这样做时我一直收到错误的分配或没有错误,但操作不会通过...这可能看起来非常丑陋或糟糕,但关于如何根据文本是否为 25-1
感谢任何能提供帮助的人。
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');
}
}
最佳答案
删除innerHTML()
中的()
。
应该是:
document.body.innerHTML = "some HTML";
请注意,它不是函数。这是一个属性。
例如这样做:
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');
关于javascript - innerHTML 上的错误分配替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22914040/