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 [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 -~----------~----~----~----~------~----~------~--~---
