Can anyone tell me: 1) why my string appears twice; 2) how to make it appear just once?
I'm trying to insert code at the top of every viewed page. Obviously, document.body appends the string to the closing body tag which is not what I want. What could I use to insert my code as the first childnode under 'body'?
I'm trying to write a script (my first) that loops through some table rows and gets some data from another page using gm_xmlhttprequests. It works if I keep the loop to one, but if I try and loop through all the rows, and therefore have say 10-20 gm_xmlhttprequests, the script just seems to fail. But if I put an alert inside each gm_xmlhttprequest, and wait a bit before dismissing the alert, the gm_xmlhttprequest will succeed and the data gets updated as planned. It seems as if the gm_xmlhttprequests don't block, or the script keeps executing without waiting for the requests to finish. I don't have any listeners on the script, I just want it all to load when the page loads. Also, I looked at the javascript console and it doesn't have any errors about the gm_xmlhttprequests.
I am trying to learn some javascript at the moment and thought a simple greasemonkey script might be a good way to start.What I want the script to do is to replace an existing url on a website with a different url from another location within the website.
E.G. replace "/mailbox.php?inbox" with "/account.php?action=mybookmarks"
There are a lot of examples of replacing existing urls with different ones on the web but they all use id's to locate and replace urls.
This script is for a site I visit often and since I dont own it I dont have the ability to add id tags to the appropriate a tags, this makes writing this script a lot more difficult.This is the code I have so far;
would like to know a tool that could give me a clue on where is the error in a greasemonkey script that i'm working on. I'm using notepad, what tool could "run" the script and tell me where is the error?
What I would like to do is watch a countdown timer on a page, like the ones on swoopo.co.uk and then perfom an action depending on what time is left on the timer.
I've installed DOM inspector on Firefox and poked around with javascript shell and I think I've figured out how to read the timer and assign that to a variable, something like this -
var timer=document.getElementById('counter_index_page_162980').innerHTML;
Now I need to watch that so I guessed this would do -
while (timer!=="00:00:01") { var timer=document.getElementById('counter_index_page_162980').innerHTML; } alert('timer at 1 sec!');
But that just brings up an "unresponsive script" error in my browser.
Am I even close to the mark? I know I'm not going to win any auctions with this but I've already paid for the bids so I may as well use them now.
I'm a newbie to JavaScript and Greasemonkey and just started learning with 'Dive Into Greasemonkey'. I looked for an example on the web, but unfortunately I'm still missing something...
I have a text file which is a simple database:
Key01 Text01 Url01 Key02 Text02 Url02 ....
I'd like to insert after
<a href="anUrl" class="thisClass">Key01<a>
the element
<a href="Url01">Text01<a>
I tried to reuse the "Dumb Quotes" from 'Dive Into Greasemonkey' by replacing
I've just started some JavaScript development, but have run into a bit of a problem with a Greasemonkey script I'm working on. This script is for personal use. I'm doing a variety of things on a page, including auto-refreshing it. I want to display the number of clicks (preferably just on links) since the last refresh.
I have a bookmarklet which copies a marked set of characters into a searchpage in our dictionary. If nothing is copied, a window opens where you can type a word.
BTW, it is for firefox 2.0.
javascript:s=window.getSelection();if(s=='')for(i= 0;i<frames.length;i++){s=frames[i].document.getSelection();if(s)break;}if(!s)void(s= prompt('some text.',''));if(s){test=open('URL/search.pl?searchphrase='+escape(s));test.focus();} This works well.
We have another search /command which needs to be finished with &search= after the searchphrase
searchphrase="here comes the markedtyped set of characters"&search=
Can anyone of you help me changing the bookmarklet or point me to a site where I can read more about this?
I've found examples of bookmarklets that select a URL from a page at random, but I'd like one that generates part of the URL at random.
If you have a bunch of images that are named: mydomain.com/images/abcd.jpg where abcd is can be any combination of 4 lowercase letters - is there a way of having the bookmarklet generate the letters randomly when clicked?
I'm able to do it using AppleScript & Safari but would like it to work from within Safari - which is missing the "Scripts" menu that most Apple apps have :(
It looks as if bookmarklets are the only option, but I've only ever used javascript to select randomly from existing arrays of images and don't fancy typing in the names of a couple of thousand images...
Download the attached file, rename it read.html and open it. Drag the "read" link onto your Favorites|Links toolbar, and acknowlege the warning dialog. Then, from anyone's page, click the "read" bookmarklet and read along with it.
My basic premise is that vowels and digits make for a place to pause momentarily (90ms) during reading. If it reads too fast or slow, you can adust the delay factor accordingly.
When publishing bookmarklets, we put the bookmarklet code in anchor tag like this:
<a href="javascript: alert('test');"name </a>
Some characters of the code need to be escaped. For example, double quotes need to be escaped as %22 like in this example: <a href="javascript: var doubleQuote = '%22' alert(doubleQuote);"> name </a>
Question: Is double quotes the only thing that need to be escaped?
I have seen examples of escaping spaces as %20, but it seems unnecessary in most browsers i have used.
I'm using the following javascript bookmarklet for creating del.icio.us posts, and it works fine, but i've been trying to augment it with "document.getSelection" and have not gotten it to work.
the code is: javascript:q=location.href;p=document.title;void(open('http://del.icio.us/fogboy?v=3&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title),'delicious%20',%20'toolbar=no,width=740,height=700'))
and it works fine (to test of course you'd have to change the del.icio.us username in there), except it doesn't have the "document.getSelection" syntax which would make it so highlighted text on a page was put in the "notes" field. i've tried about 5 different ways of writing that, based on other versions i've seen around. i would love to know exactly the right syntax to use to get this working.
I found this bookmarklet which I'm using in Firefox Would anyone here be willing to modify it to display its results in a new tab, instead of using the current tab?
Code: javascript:q = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); if (!q) q = prompt("You didn't select any text. Enter a search phrase:", ""); if (q!=null) location=("http://www.google.com/search?num=100&q=site:" + escape(location.hostname) + " "" + escape(q.replace(/"/g,"")) + """).replace(/ /g, "+"); void 0
I have bookmarklets with a # in their urls but safari changes the # to %23. And unfortunately, the bookmarklet does not work with %23. You need to change it back manually to #.
I need this bookmarklet (below) to open in a new window and display the info there. It needs to work in both FF and IE. It would be in one line in the bookmarklet but I expanded it for readability. It should work against our site: [URL]
Its the "To English" bookmarklet as featured on lifehacker (http://lifehacker.com/5168984/to-english-bookmarklet-quickly-easily-translates-any-text-with-one-click).
I have found a script for opening all linked images of one page in a new window and displaying all images in full size inline. It works so far, however:
I want the images to be displays in the current window i am in instead of opening a new window.
I am trying to make a twitter bookmarklet that will tweet the current page, I currently have this code: Javascript:window.open('[URL]'+self.location) But when I try it, it changes the page its tweeting to just show [object Window].