greasemonkey

How can I click a <li> item with Greasemonkey?

久未见 提交于 2019-12-06 16:00:18
问题 <ul class="myList clearfix" id="thismyList"> <li class="myBullet" id="answer1">blabla1</li> <li class="myBullet" id="answer2">blabla2</li> <li class="myBullet" id="answer3">blabla3</li> </ul> In this page, how can I automatically click item blabla2 ? 回答1: The shortest and most powerful is probably the XPath way (btw - it's one of the few w3 specifications that are actually a very good and helpful read). You can have almost any conditions you want to have. var xresult = document.evaluate("//*

greasemonkey insert javascript

随声附和 提交于 2019-12-06 14:49:01
I have a bookmarklet, clicking the bookmarklet includes a PHP script (evaluated as a JavaScript file) to the page few table values and select values passed as GET parameters. The PHP script writes the page data to the MySQL database, and outputs a success message that is treated as JavaScript code and executed by the browser. Is there any possibility to do this using greasemonkey and call this function when a existing button is clicked on the web page. I wrote the above bookmarklet inspired by this tutorial. http://tutorialzine.com/2010/04/simple-bookmarking-app-php-javascript-mysql/ This is

Access an existing copy of jQuery on the target page

时光毁灭记忆、已成空白 提交于 2019-12-06 12:59:52
I am writing a small userscript to get some content from a server and add it to a tie. The site has jQuery, how can I just use the site's jQuery instead of @require (because Chrome doesn't support this now)? Use an existing copy of jQuery with code like this: function main () { /*--- Put all of your code here. Use jquery with $ or however the target page uses it. */ } function addJS_Node (text, s_URL, funcToRun) { var D = document; var scriptNode = D.createElement ('script'); scriptNode.type = "text/javascript"; if (text) scriptNode.textContent = text; if (s_URL) scriptNode.src = s_URL; if

How do I unbind jquery event handlers in greasemonkey?

谁说胖子不能爱 提交于 2019-12-06 12:18:29
$("p").click(function(){alert('clicked')}); $("p").unbind('click'); Within greasemonkey the click event does not unbind. I believe this is caused by greasemonkey's security model wrapping the associated event object from the first line in XPCNativeWrapper, causing the second line to be unable to "find" it. However, I can't seem to find a workaround. Any suggestions? UPDATE: Something like the following does work in greasemonkey. So I'm still thinking it's an XPCNativeWrapper issue that I can't find a way to resolve. $("p").click(function(){alert('clicked'); $(this).unbind('click')}); I think

Is there a way to exit a Greasemonkey script?

大憨熊 提交于 2019-12-06 11:24:27
I know that you can use return; to return from a Greasemonkey script, but only if you aren't in another function. For example, this won't work: // Begin greasemonkey script function a(){ return; // Only returns from the function, not the script } // End greasemonkey script Is there a built in Greasemonkey function that would allow me to halt execution of the script, from anywhere in the script? Thank you, Yeah, you can probably do something like: (function loop(){ setTimeout(function(){ if(parameter === "abort") { throw new Error("Stopped JavaScript."); } loop(); }, 1000); })(parameter); You

Deleting child nodes of a div node

一世执手 提交于 2019-12-06 11:11:54
I have following codes to remove child nodes of a div node. Are both of these codes correct? while(innerWindowContentBox.hasChildNodes()) innerWindowContentBox.removeChild(innerWindowContentBox.childNodes[0]); Other is innerWindowContentBox.innerHTML = ''; Note that the code is for a Greasemonkey script so IE support is not required. Both bits of code will get the job done but use the DOM approach ( that is while(innerWindowContentBox.hasChildNodes() ... ). Advantages: It's quite a bit faster. See this speed comparison at jsperf.com . On the sample HTML (hundreds of nodes, each with event

How to use keydown event in textarea?

不想你离开。 提交于 2019-12-06 10:34:23
问题 I am not very used to using javascript but I have gotten sick of manually repeating a tast at work. When I write in a discussion forum I need a quick short command, like Ctrl-Alt-z, to insert some text into a textarea object. I have already written a function that inserts the text at the text cursor insertAtCursor(text). The ID of the textarea is "content". I know how to solve the problem of checking for key combinations. The problem I have is basically to check for any keyboard input at all.

How can I prevent a webpage from detecting I am running a script?

跟風遠走 提交于 2019-12-06 10:26:53
问题 After experimenting with scripts on facebook.com, I noticed that for a couple of minutes it didn't allow me to connect to facebook.com. This happened more than one time so I suspect that Facebook doesn't like to mess with their code using userscripts. The Stack Overflow question Can a website know if I am running a userscript? answers the multiple ways a website can detect scripts. Now I want to know how I can fool a website to not detect any scripts I may be running. Is there a way to know

jQuery click() not working in a Greasemonkey/Tampermonkey script

孤街醉人 提交于 2019-12-06 10:10:09
I am having issues triggering a jQuery click through Greasemonkey/Tampermonkey... jQuery('button').each(function() { jQuery(this).css('background', 'red'); jQuery(this).click(); location.assign("javascript:jQuery(this).click();void(0)"); }​ As you can see I've even tried the location.assign hack but nothing will work, no errors in the console either. Funny thing is that yes, the background colour does change to red so I am assuming it's something in the way .click() works that is different from other jQuery methods. jQuery's .click() is just a shortcut for jQuery's .trigger() and from the Docs

jQuery conflict between Greasemonkey script and page [duplicate]

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 09:06:28
This question already has answers here : Can I use multiple versions of jQuery on the same page? (7 answers) jQuery in Greasemonkey 1.0 conflicts with websites using jQuery (3 answers) Closed 6 years ago . I'm writing an add-on for Greasemonkey and using jQuery 1.9.1 (via @require ). But there's already jQuery 1.1.2 on the website: <script type="text/javascript" language="JavaScript" src="jquery.js" >... When I run the script it says "TypeError: jQuery.browser is undefined". I tried adding jQuery migrate to the Greasemonkey script - but it's still not working. I think I need to replace the old