greasemonkey

How do I include a remote javascript file in a Greasemonkey script?

I'm trying to write a Greasemonkey script, and would like to use the jQuery library to do so, but I'm not quite sure how I would include jQuery from a web address to get rolling. How would I include jQuery (from Google's web server) into the greasemonkey script so that I can just go: $(document).ready(function(){ // Greasemonkey stuf...

How to stop javascript alert from showing after pressing ok

I want to show an alert if I have something in my Facebook inbox. I think it can be easily accomplished using userscripts... this is what I have so far (thanks to the guys at the userscripts forums): document.addEventListener("DOMNodeInserted", function() { var count; if ((count=parseInt(document.getElementById("fb_menu_inbox_unread...

javascript cloneNode with events

I am working on a greasemonkey script for gmail where i need to make a copy of the "Inbox" link. Using cloneNode works ok, but i think there's an onclick event that gets attached to it at runtime. So, this is a two part question: 1. Is there a way to see what events are attached to a node? 2. Is there a way to copy those events as well?...

Greasemonkey script to pause video playback on non-active tabs

Often when browsing in Firefox, I'll right click on a link, and open it in a separate tab to view later, and go on reading the current page. When the link is a Youtube script, however, playback starts immediately even though the tab isn't active. Other video players (like fora.tv and TED.com) don't start playback until you activate that ...

Using javascript for pinging a webapp to keep session open

I'm writing a greasemonkey script to keep session open on a webapp I use for work. Which javascript command would you use to create some feedback with the server and ensure the session doesn't fall without having to bother the user making a complete refresh of the page? ...

How can I use jQuery in Greasemonkey?

I tried putting this line but it doesn't work: // @require http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js jQuery doesn't work in Greasemonkey at all. Is there other way to use jQuery in Greasemonkey? -- For all the people who have the same problem, you must upload the file to greasespot then install it from there....

Greasemonkey + jQuery: using GM_setValue() within an event callback

I'm trying to set data in long-term storage in a GreaseMonkey script, except that GM_setValue() seems to fail silently: $("a#linkid").click(function() { GM_setValue("foo", 123); // doesn't work, but does not generate error }); GM_setValue("bar", 123); // works properly, value is set ...

I'm having a problem selecting an element in jQuery

Hi, I'm using selectorgadget to help me select elements on the document. But when I used it on jQuery it doesn't work. The nth-child selector seems not to work for me. <div id = "wrap"> <div class = "book"> <div class = "chapter"> <p class = "text"> <table> <tbody> <tr> <td>Title</td> <td>...

Greasemonkey and Gmail - parsing message contents

I want to read the contents of Gmail messages and add some fancyness on links. Here's some code: unsafeWindow.gmonkey.load("1.0", function(gmail){ gmail.registerViewChangeCallback(function(){ if (gmail.getActiveViewType && gmail.getActiveViewType() == "cv") { var viewElement = gmail.getActiveViewElement() // Do things ...

Why won't an HTML form load into a Javascript-created iframe?

So, in pure HTML, I can create a form that loads its results into an iframe (instead of moving the user to the result url). <html> <head> <title>Google Preview</title> <style>iframe { width: 800px; height: 600px }</style> </head> <body> <form method='get' action='http://www.google.com/search' target='results'> <l...

How to write user scripts so they work in both Opera and Greasemonkey.

I'm getting into user scripts at the moment. I know Opera is compatible with many aspects of Greasemonkey scripts, but not so much with other aspects. The GM functions emulation script will be required on Opera, and at the start I have if(window.opera) { var unsafeWindow = window; } But beyond that, what other things should I kee...

Detect iFrame embedding in Javascript

I have an application that has a certain page -- let's call it Page A. Page A is sometimes a top-level page, but also sometimes is embedded as an iframe within page B. All pages come from the same server and there are no cross-domain issues. I have a greasemonkey script that runs on page A. How can the greasemonkey script detect whether...

Get image data in Javascript?

I have a regular HTML page with some images (just regular IMG HTML tags). I'd like to get their content, base64 encoded preferably, without the need to redownload the image (ie. it's already loaded by the browser, so now I want the content). I'd love to achieve that with Greasemonkey and Firefox. ...

greasemonkey script that outputs all data corresponding to xpath

I would like to write a greasemonkey script that given an xpath returns all of the output of that xpath executed on the current page in a .txt file with one result per row. How do I do this? EDIT: Its ok if the output is not written to a file. I just want to have it displayed. ...

How can I call a function in an iframe's parent using Greasemonkey

I have a Greasemonkey script which adds an iframe to the page (call it Page 1). The iframe contains another page (call it Page 2). The script runs on Page 2 as well. Pages 1 and 2 are on different domains. I'd like to allow code running in Page 2 to call a function on Page 1. Given the lower restrictions on Greasemonkey code, is thi...

How can I provide a limited interface to Greasemonkey's GM_xmlhttpRequest to my page's Javascript?

I have a Greasemonkey userscript which runs most of its code in an unprivileged context by inserting a <script> tag like so: function code { ... } var script = document.createElement("script"); script.type = "application/javascript"; script.innerHTML = "(" + code + ")();"; document.body.appendChild(script); This avoids the need to ...

Why does the jQuery 'nth-child' selector not work inside GreaseMonkey (0.8)?

I believe jQuery's :nth-child selector doesn't work inside GreaseMonkey 0.8. (At the bottom is a quick GM script to test this.) Why is this? Is this a known limitation from working inside GreaseMonkey? Can anyone recommend a way around this? Also, why is it that some (definitely not all) jQuery queries run much slower inside GreaseMonk...

How do I replace a text box with a drop down populate by web service in fogbugz using greasemonkey script?

I want to replace the 'client' field text box in fogbugz when you edit a case to be a drop down instead populated from a separate web service that will keep the client options up to date in our fogbugz. Is this possible? Will the choice they select in the drop down be able to save the same way it would if they had typed it into the text ...

Opera scripts and storing states(like GM_SetValue in greasemonkey)

Is there a way to store state of user script in opera? In GreaseMonkey one can use GM_SetValue/GM_GetValue. I saw one script that emulates them in opera using cookies but I don't like this idea for several reasons(mainly for limitied size of cookies). Is there another way to store state? ...

What JavaScript object copy function works with greasemonkey?

I know there is another question related to copying objects in JavaScript here, but the code they provide does not work with greasemonkey. From what I was able to trace, the code for the accepted answer dies/ stops at the line : var temp = new obj.constructor(); Is there any way to see what went wrong ? It's not really necessary I use...