I have an old greasemonkey script that used to start refreshing pages on new tab:
// ==UserScript==
// @name script
// @namespace http://localhost
// @description Monitor the location page and catch the egg you want.
// @include http://192.168.10.1/index/*
// @version 1
// @grant none
// ==/UserScript==
var container = document.getElementsByClassName("A");
for (var l = 0; l < container.length; l++) {
container[l].setAttribute('id', 'A');
var A = document.getElementById("A");
var divs = A.getElementsByTagName("div");
for (var i = 0; i < divs.length; i++) {
if ((divs[i].innerHTML.indexOf("failure") != -1) || (divs[i].innerHTML.indexOf("error") != -1)) {
var div = divs[i];
var link = divs[i].innerHTML.href;
for (var b = 0; b < div.childNodes.length; b++) {
var test = div.childNodes[0].href;
//window.location.href = test;
open_in_new_tab(test);
}
}
}
}
setTimeout(function () { window.location.href = window.location.href }, 800);
function open_in_new_tab(url )
{
var win=window.open(url, '_blank');
win.focus();
}
I cant get it to work anymore, I assume that since firefox 57+ some features have changed, Is it possible to fix/debug this, so that it'll work again?
the relevant html im trying to run this on:
<!DOCTYPE html>
<html>
<head><title></title>
<link rel="mask-icon" href="//s.192.168.10.1/mask-icon.svg" color="#990e0e">
<link type="text/css" rel="stylesheet" href="//s.192.168.10.1/cache/css/e/etsmpm.css" data-modules="1k">
<link type="text/css" rel="stylesheet" href="//s.192.168.10.1/cache/css/c/cze0ax.css" data-modules="3q">
<link type="text/css" rel="stylesheet" href="//s.192.168.10.1/cache/css/1/1vbpas.css" data-modules="1c,1e,1,3h,3g,3n,3o,3p">
</head><body class="_3q_7">
<div class="_3p_0">
<div class="_3o_6">
<h1 class="_3o_1">
<a href="/?r=1">
<img src="//s.192.168.10.1/cache/images/b/bvi5yh.png" alt="Apache" width="388" height="120">
</a></h1><div class="_3o_3"> Logged in as <a href="/user/Test">Test</a>
<a href="/notifications"><span title="No unread notifications" class="_3g_3" id="95f64d6ba8"><i class="_3h_0 _3h_4"></i></span></a>
<a href="/market">787<i class="_3h_0 _3h_b"></i></a>
<a href="/help/time" class="_3o_4"><span title="Night:" class="_3g_3 _3h_0 _3h_2" id="c1f1299e22"></span> 3:07 am EST</a>
<a href="/logout">Log out</a>
</div><div class="_3o_9">
<a href="/?r=2">Route</a>
<a href="/account">Account</a>
<a href="/items">Items</a>
<a href="/trading">Trading</a>
<a href="/help">Help</a>
<a href="http://forums.192.168.10.1/" target="_blank">Forum</a>
</div></div>
<div class="_3p_6"></div>
<div class="_3p_7">
<div id="middle">
<h1>Index2</h1>
<ul class="_1k_0"><li>
<a href="/index/5">index5</a></li>
<li><a href="/index/1">index1</a></li>
<li style="font-weight:bold">
<a href="/index/2">index2</a></li><li><a href="/index/3">index3</a></li><li><a href="/index/4">index4</a></li><li><a href="/index/6">index6</a></li></ul><section>
<div class="A" id="44c39a0cc4"><div><a aria-labeledby="ef21da66ab" href="/get/22eKE"><img src="//s.192.168.10.1/cache/images/8/8itcaf.gif" alt="A" width="26" height="28"></a><br>
<span id="ef21da66ab">valid deascription</span></div><div><a aria-labeledby="1d460c3daf" href="/get/tg9ZF">
<img src="//s.192.168.10.1/cache/images/8/8itcaf.gif" alt="A" width="26" height="28"></a><br>
<span id="1d460c3daf">valid description</span></div><div><a aria-labeledby="1758a88110" href="/get/1qRTn">
<img src="//s.192.168.10.1/cache/images/8/8itcaf.gif" alt="A" width="26" height="28"></a><br>
<span id="1758a88110">error</span></div></div><div class="online">Users viewing this page: 1</div>
</section>
<noscript><a href="https://secure.fastclick.net/w/click.here?sid=68085&m=1&c=1" target="_blank">
<img src="https://secure.fastclick.net/w/get.media?sid=68085&m=1&tp=5&d=s&c=1&vcm_acv=1.4" style="width:728px;height:90px"></a></noscript>
</ins></div><div class="_3p_5">
</div></div></div><div class="_3p_8"></div>
</div><script>window.onerror=function(b,c,d,e,a){navigator.sendBeacon("/el",JSON.stringify([b,c,d,e,a&&a.stack]))};window.onbeforeunload=function(){delete window.onerror};(function(i,s,o,g,r,a,m){i["GoogleAnalyticsObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,"script","//www.google-analytics.com/analytics.js","ga");ga("create","UA-2864033-4","auto");ga("set","dimension1","new");ga("set","userId",89632);ga("send","pageview");!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version="2.0";n.queue=[];t=b.createElement(e);t.async=!0;t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,document,"script","https://connect.facebook.net/en_US/fbevents.js");fbq("init","1405173446393356");fbq("track","PageView");</script><noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=1405173446393356&ev=PageView&noscript=1"></noscript><script src="//s.192.168.10.1/cache/js/c/c7yxzl.js" crossorigin="anonymous" defer></script><script>window.addEventListener('DOMContentLoaded',function(){global=window;require.config({"enforceDefine":true,"waitSeconds":60,"paths":{"1mh":"\/\/s.192.168.10.1\/cache\/js\/9\/9xrboc","2":"\/\/s.192.168.10.1\/cache\/js\/2\/2mcg3g","1cc":"\/\/s.192.168.10.1\/cache\/js\/7\/7y8rpz","1gi":"\/\/s.192.168.10.1\/cache\/js\/a\/a1ys2f","1gn":"\/\/s.192.168.10.1\/cache\/js\/8\/8zhrpq","b":"\/\/s.192.168.10.1\/cache\/js\/a\/asqoew"},"bundles":[]});require(["1mh"],function(_){_.i(document.getElementById('44c39a0cc4'))});require(["1cc"],function(_){_.init()});require(["1gi"],function(_){_.bindToElement(document.getElementById('95f64d6ba8'),"auto")});require(["1gi"],function(_){_.bindToElement(document.getElementById('c1f1299e22'),"auto")});require(["b"],function(_){_.init(document.getElementById('75079eec42'))});})</script></body></html>
when i tried running it vie firefox console it did find the text and open the link in new tab i just cant get it to refresh and repeat the process with greasemonkey
There are issues with the script post in your post.
What is stuff as it would break the code?
What is the use of open_in_new_tab()
as it is not used?
800 means 800 milliseconds. It is impractical to reload a page every 0.8 of a second as it would often take longer to load a page.
Here is a simple example...
// ==UserScript==
// @name script
// @namespace http://localhost
// @description Monitor the location page and catch the egg you want.
// @match http://192.168.10.1/index/*
// @version 1
// @grant none
// ==/UserScript==
setTimeout(function() { location.reload(); }, 5000);
Please note that some pages can interfere with reload()
for example with unload
event.
Here is an example userscript ...
// ==UserScript==
// @name script
// @namespace http://localhost
// @description Monitor the location page and catch the egg you want.
// @include http://192.168.10.1/index/*
// @version 1
// @grant none
// ==/UserScript==
setTimeout(function() { location.reload(); }, 2000); // relaod after 2 seconds
document.querySelectorAll('.A div').forEach(item => { // get all div in class A
if(/failure|error/.test(item.textContent)) { // test div content
const a = item.querySelector('a'); // get link in div
a && openInTab(a.href); // if found, open in new tab
}
}):
function openInTab(url) {
const win = window.open(url, '_blank');
win.focus();
}