Saturday, 24 August 2013
Only target non-active buttons with Greasemonkey
Only target non-active buttons with Greasemonkey References I\'m trying to put together a short Greasemonkey script for the site Lift.do that will click all my connections\' \"Prop\" buttons. These function like the \'like\' button on Facebook - you can turn them on and off. The problem is, when reloading the page, the script will deactivate buttons it activated previously. So how do I modify the script to only target non-active \"Prop\" buttons? I used Brock Adams\' tutorial on this page as a guide - Choosing and activating the right controls on an AJAX-driven site - and in fact most everything below is a direct copy/paste from info I got from answers to StackExchange questions. // ==UserScript== // @name Lift Propper // @namespace https://lift.do/app/activity // @description Props friends\' lifts automatically // @include https://lift.do/app/activity // @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @version 1 // @grant none // ==/UserScript== waitForKeyElements (\"a.action-button\", triggerMostButtons); function triggerMostButtons (jNode) { triggerMouseEvent (jNode[0], \"mouseover\"); triggerMouseEvent (jNode[0], \"mousedown\"); triggerMouseEvent (jNode[0], \"click\"); //only needs click event, I think triggerMouseEvent (jNode[0], \"mouseup\"); } function triggerMouseEvent (node, eventType) { var clickEvent = document.createEvent(\'MouseEvents\'); clickEvent.initEvent (eventType, true, true); node.dispatchEvent (clickEvent); } I copied the URL\'s source and put it up here: http://pastebin.com/mfF8tbdC , although I don\'t know how much help that is because the content of the activity feed looks like it\'s coming in via AJAX. The URL I\'m trying to work on is https://lift.do/app/activity , but that\'s tied to my specific account, of course. Here\'s the html of the node I\'m targeting (from firebug): And here\'s the same button in the active state: These two have the same CSS Path. So how do I, using waitForKeyElements, distinguish between the two? How to target only non-active Prop buttons?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment