Looking for Script troubleshooting assistance

View: New views
4 Messages — Rating Filter:   Alert me  

Looking for Script troubleshooting assistance

by Justin-134 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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 greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Looking for Script troubleshooting assistance

by Erik Vold-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I haven't looked at the source, I just want to confirm that the site
didn't change first..

E

On Oct 27, 8:30 am, Justin <jsad...@...> wrote:

> 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 greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Looking for Script troubleshooting assistance

by cc-21 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


A couple of general points before I start noting specifics. First, the
script seems to use a good many rather crude or old-fashioned
techniques, such as constructing HTML from strings (rather than using
createElement and appendChild), and searching through elements by brute
force, rather than using XPath (document.evaluate and friends). But as
long as the script works, these doesn't matter as much.

Also, try going back to an earlier version of Firefox and Greasemonkey
(on a separate profile; use the [Profile
Manager](http://kb.mozillazine.org/Profile_Manager#Creating_a_new_profile)
for that), and see if the problem goes away. It might actually be that
the website has been updated.

Oh, and by the way, what exactly doesn't work? Does the script create
its checkboxes properly, or are those failing? Is it unable to
automatically refresh the page, or are jobs not being automatically
accepted? This is pretty important information.

On 2009-10-27 08:30, Justin wrote:
> -----------------------------------
> // ==UserScript==
> // @name           Carrier Point Auto Refresh
> // @description    Continually refresh offers, waiting for new loads
> // @include        http://*carrierpoint.com/*
> // @include        https://*carrierpoint.com/*
> // ==/UserScript==
>    
It would be nice to have a copy of the pages (perhaps cleaned up) that
this actually runs on. A quick look at carrierpoint.com does not suggest
anything interesting without requiring a login. (In point of fact, it's
probably essential for any kind of detailed debugging, as nothing is
jumping out yet. We're not psychic.)

> 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>';
>    
This is sorta crummy, as mentioned; a better way, stylistically, is to
either manually create the elements in question, or to use inline XML like
var control = <>
<div>
<table style="..." />
</div>
</>;

which should work in modern Firefoxes (would that be Firefoxen? :-)).
> var to;
>
> unsafeWindow.addEventListener("load",function(e) {
>    
Why unsafeWindow? That's, well, unsafe. (Long story, but basically a
very bad idea for anything other than pages that you control. Insecure,
could leak information, could steal passwords, all kinds of horrid stuff.)

> 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 greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Looking for Script troubleshooting assistance

by Justin-134 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


@ Erik: The site hasn't changed--it was working fine untill I started
touching it...


@cc

I have very basic programming skills, this was however written in 2006
or earlier, so that might explain some poor programming techniques.
Whats working and whats not, here's where it gets weird. On any PC I
install it, the boxes are there, however when you check them nothing
happens. On the PC where it was always working and I sort of "broke"
it, the refresh button is checked and working, however as the page
refreshes no matter what you check or uncheck it always reverts back
to the accept button being unchecked and the refresh button being
checked.

I will try messing with older versions of firefox/greasemonkey

On Oct 28, 1:43 am, cc <carlcl...@...> wrote:

> A couple of general points before I start noting specifics. First, the
> script seems to use a good many rather crude or old-fashioned
> techniques, such as constructing HTML from strings (rather than using
> createElement and appendChild), and searching through elements by brute
> force, rather than using XPath (document.evaluate and friends). But as
> long as the script works, these doesn't matter as much.
>
> Also, try going back to an earlier version of Firefox and Greasemonkey
> (on a separate profile; use the [Profile
> Manager](http://kb.mozillazine.org/Profile_Manager#Creating_a_new_profile)
> for that), and see if the problem goes away. It might actually be that
> the website has been updated.
>
> Oh, and by the way, what exactly doesn't work? Does the script create
> its checkboxes properly, or are those failing? Is it unable to
> automatically refresh the page, or are jobs not being automatically
> accepted? This is pretty important information.
>
> On 2009-10-27 08:30, Justin wrote:> -----------------------------------
> > // ==UserScript==
> > // @name           Carrier Point Auto Refresh
> > // @description    Continually refresh offers, waiting for new loads
> > // @include        http://*carrierpoint.com/*
> > // @include        https://*carrierpoint.com/*
> > // ==/UserScript==
>
> It would be nice to have a copy of the pages (perhaps cleaned up) that
> this actually runs on. A quick look at carrierpoint.com does not suggest
> anything interesting without requiring a login. (In point of fact, it's
> probably essential for any kind of detailed debugging, as nothing is
> jumping out yet. We're not psychic.)> 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>';
>
> This is sorta crummy, as mentioned; a better way, stylistically, is to
> either manually create the elements in question, or to use inline XML like
> var control = <>
> <div>
> <table style="..." />
> </div>
> </>;
>
> which should work in modern Firefoxes (would that be Firefoxen? :-)).> var to;
>
> > unsafeWindow.addEventListener("load",function(e) {
>
> Why unsafeWindow? That's, well, unsafe. (Long story, but basically a
> very bad idea for anything other than pages that you control. Insecure,
> could leak information, could steal passwords, all kinds of horrid stuff.)
>
>
>
> >    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;
> >            }
> >    }
> > }- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "greasemonkey-users" group.
To post to this group, send email to greasemonkey-users@...
To unsubscribe from this group, send email to greasemonkey-users+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---