Hi, I have a script here that is no longer working properally and the
person who wrote it no longer works at my company. The script below is
for a trucking website that posts available loads, and it will add 2
checkboxes, when clicked one will refresh the page, and the 2nd one
will accept any loads that appear. It was working perfectly, then I
updated firefox + greasemonkey and it no longer functions.

Can anyone help figure out what is wrong with it?

-Justin


-----------------------------------
// ==UserScript==
// @name           Carrier Point Auto Refresh
// @description    Continually refresh offers, waiting for new loads
// @include        http://*carrierpoint.com/*
// @include        https://*carrierpoint.com/*
// ==/UserScript==

var control = '<div >' +
'<table style="font-size: 0.6em;"><tr><td><label for="refresh">Auto
Refresh:</label></td>' +
'<td><input type="checkbox" id="refresh" onchange="setRefresh
(this.checked)">' +
' (<a href="#" onclick="setDelay()">set delay</a>)</td></tr>' +
'<tr><td><label for="respond">Auto Accept:</label></td>' +
'<td><input type="checkbox" id="respond" onChange="setRespond
(this.checked)"></td></tr></table>' +
'</div>';

var to;

unsafeWindow.addEventListener("load",function(e) {
        var tds = document.getElementsByTagName("td");
        var sel = document.getElementsByTagName("select");
        var respond = null;
        var noships = null;
        for(var i = 0; i< tds.length; i++) {
                if(tds[i].innerHTML.search("Respond to Offers") >= 0) {
                        respond = tds[i];
                } else if(tds[i].innerHTML.search("No shipments found") >= 0) {
                        noships = tds[i];
                }
        }
        for( var i = 0; i < sel.length; i++ ) {
                if( sel[i].name == "postedByUserId" ) {
                        sel = sel[i];
                        break;
                }
        }
        if( !sel.options || sel.options[sel.selectedIndex].value != "2930" )
{
                respond = false;
        }
        if(respond) {
                respond.innerHTML += control;
                if(GM_getValue("refresh", false)) {
                        document.getElementById("refresh").checked = true;
                        startLoop();
                }
                if(GM_getValue("respond", false)) {
                        document.getElementById("respond").checked = true;
                        if(!noships) {
                                checkAll(document, true, false);
                                window.focus();
                                if(GM_getValue("refresh", false)) {
                                        startLoop(0);
                                }
                        }
                }
        }

        }, false
);


unsafeWindow.setRefresh = function(enabled) {
        GM_setValue("refresh", enabled);
        if(enabled) {
                startLoop();
                window.status = "Auto Refresh is now enabled.";
        } else {
                window.clearTimeout(to);
                window.status = "Auto Refresh is now disabled.";
        }
}
unsafeWindow.setRespond = function(enabled) {
        GM_setValue("respond", enabled);
        if(enabled) {
                checkAll(document,true,false);
                window.status = "Auto Accept is now enabled.";
        } else {
                checkAll(document,false,false);
                window.status = "Auto Accept is now disabled.";
        }
}

function startLoop(delay) {
        if(to) { window.clearTimeout(to); }
        unsafeWindow.refreshLoop((delay == null?GM_getValue("seconds",
5):delay));
}

unsafeWindow.refreshLoop = function(count) {
        if(count == 0) {
                window.status = "Refreshing...";
                document.forms[0].submit();
        } else {
                to = window.setTimeout("refreshLoop(" + (count - 1) + ")", 
1000);
                window.status = "Refreshing in " + count + " seconds...";
        }
}

unsafeWindow.setDelay = function() {
        GM_setValue("seconds", prompt( "Please enter of number of seconds to
wait between refreshes.", GM_getValue("seconds", 5), "Set Refresh
Rate" ) );
        window.status = "Set refresh delay to " + GM_getValue("seconds", 5) +
" seconds";
}



function checkAll(doc,accept,decline) {
        if(!doc) { return false; }
        inputs = doc.getElementsByTagName("input");
        for( var i = 0; i < inputs.length; i++ ) {
                if( inputs[i].getAttribute("value") == "accept" ) {
                        inputs[i].checked = accept;
                } else if( inputs[i].getAttribute("value") == "decline" ) {
                        inputs[i].checked = decline;
                }
        }
}



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to