Recent posts by Raffles

Subscribe to Recent posts by Raffles 13 posts found

Nov 26, 2007
Raffles 13 posts

Topic: Script development / Gmail - class names

It looks like they don't change, but you don't need to use them, since Google have very nicely provided this:

http://code.google.com/p/gmail-greasemonkey/wik...

 
Nov 18, 2007
Raffles 13 posts

Topic: Script development / Canceling onclick default action when also using ondblclick

I've edited my post above because I replied from a page that had been open overnight, so I only saw Descriptor's first post.

 
Nov 18, 2007
Raffles 13 posts

Topic: Script development / Canceling onclick default action when also using ondblclick

Double-clicking may not be cool under most circumstances, but in the script this is for (http://userscripts.org/scripts/show/9750) it works I think, at least for me. The script is primarily for me, of course, and I'm sharing it on this site in case other people are interested in it.

That said, I don't like hacky things and I still feel this is somewhat hacky. There is of course an inherent problem in trying to listen for double clicks while cancelling single clicks, as Mikado pointed out. But I didn't want to add extra stuff to the box, such as an "edit this" link/button - I thought double-clicking was a clutter-free solution.

I don't understand why I should be checking event.button, event.altKey or event.ctrlKey, since the click event will register regardless.

I'll think about this a bit more. Putting all that stuff in the same function is a nice idea, Descriptor. Cheers for the input.

 
Nov 17, 2007
Raffles 13 posts

Topic: Userscripts.org discussion / Spam and malware

Lots of scripts that advertise spammers' websites.

http://userscripts.org/scripts/show/13999
http://userscripts.org/scripts/show/13998
http://userscripts.org/scripts/show/13996
http://userscripts.org/scripts/show/13988
http://userscripts.org/scripts/show/13992
http://userscripts.org/scripts/show/13990
http://userscripts.org/scripts/show/13983

And many more. A search for "scrap" will bring up loads. They all seem to have a title like "scrap all ur friends" or "scrap all yr friends".

If these people (using the term loosely) are creating the accounts with bots and bypassing the captcha perhaps some more robust account creation method is necessary. If not, then there's probably not much that can be done. :(

 
Nov 17, 2007
Raffles 13 posts

Topic: Script development / Canceling onclick default action when also using ondblclick

When a link is clicked I want it to be followed normally. When it is double-clicked, a prompt is to appear and the link is not to be followed. The problem is that with a double-click event, two click events occur of course.

I tried this and it works:

itemLink.addEventListener('click', function(e) {
e.preventDefault();
doubleClicked = false;
var l = this.href;
setTimeout(function() {
if (doubleClicked !== true) window.location.assign(l);
}, 500); // hopefully within 500ms the second click has happened
});
itemLink.addEventListener('dblclick', function() {
doubleClicked = true;
promptFunction();
}, false);

doubleClicked is of course in the global scope. My issues with this are that if you're a very slow double-clicker, the link might still get followed. But if I set it to say, 1000ms then clicking on links normally gets annoying if you have to wait 1s before they get followed.

Is there any other way to do this that I'm missing? Using setTimeout just seems very "hacky".

 
Jun 1, 2007
Raffles 13 posts

Topic: Script development / Script not adding stuff onload, not onDOMContentLoaded

Blocking JS files in the head and reinserting from the local computer is just not worth the trouble. It's actually not that bad now, I think Photobucket was probably just having some issues yesterday, it was abnormally slow.

Thanks for the help guys.

 
May 31, 2007
Raffles 13 posts

Topic: Script development / Script not adding stuff onload, not onDOMContentLoaded

I've found that blocking Google Analytics' urchin.js with adblock does help a little, but most of the slowness is I think due to the download of over 200KB of javascript in the head. Easily Adblocked, but some pretty trivial functionality in the site relies on them (lazy, bad design) and if anyone else is going to install this script, they might not have Adblock.

Descriptor, Google Analytics doesn't do ads - it logs traffic. The only thing it document.writes into the page is a small GIF image (35 bytes in size).

What makes the experience much better is to put as much of the CSS-related business into userContent.css instead of using GM_addStyle (but doesn't speed up the application of the script of course).

Thanks Arvid, I'd read that before. Wishful thinking here and I doubt it's possible, but does anyone know if a user script can add stuff to userContent.css? Also, userContent.css applies those rules as the page is loading, way before DOMContentLoaded has fired. It would be nice if GM_addStyle could somehow do this. I remember an extension that allowed you to edit userContent.css and it applied changes on page reload (not Firefox reload).

Regarding clicking STOP/ pressing Esc while the page is loading, the user script is applied even if the page's HTML has not been fully loaded. Seems like DOMContentLoaded fires when the user stops the page loading after at least some of the document body has appeared. Perhaps the ideal thing would be to fire DOMContentLoaded artificially, or simulate the user stopping the page loading without it actually happening! Not that I expect this to be possible.

 
May 31, 2007
Raffles 13 posts

Topic: Script development / Detecting end of multiple GM_xmlhttpRequests

I see now. A very nice and simple solution and better than what I currently have. I'll add some code to handle onerror as well.

Cheers guys.

 
May 30, 2007
Raffles 13 posts

Topic: Script development / Help the Noob :)

It's impossible to help you if you don't show any code...

 
May 30, 2007
Raffles 13 posts

Topic: Script development / Script not adding stuff onload, not onDOMContentLoaded

I've made a user script to make Photobucket a bit more useful, to strip out the annoying ads and use the space a bit better. It works very well so far (not completely finished yet) but the script only is applied after absolutely everything has loaded (even images) - clearly not immediately after the DOM has loaded as it is supposed to.

I've put a copy at this pastebin and as you can see, it follows this basic structure:

- Function.prototype.bind defined
- Two global vars defined
- A bunch of functions defined
- init() is called right at the end

Sometimes photobucket gets stuck for ages on "Transferring data from google-analytics.com" or on "Waiting for a.photobucket.com" and so the script isn't applied until this is over. If I click STOP, the script is immediately applied.

Can anyone see what the problem is? Thanks in advance,

Raffles

 
May 30, 2007
Raffles 13 posts

Topic: Script development / Detecting end of multiple GM_xmlhttpRequests

I can't say I fully understand what's going on there with the counter, but I found a way to implement what I wanted in the end.

Thanks for your help. :)

 
May 30, 2007
Raffles 13 posts

Topic: Script development / Detecting end of multiple GM_xmlhttpRequests

Hi,

I'm writing a script where the first time it is run, some data needs to be collected and this is done by defining an object and then adding the data to it. Data can have sub-data, so it will end up being an associative array (but using objects). Then I'm going to serialize it somehow and store it on the user's computer so it can be used every time.

This needs to be done because the data exists on several different pages and on setup, anywhere between 5 and 50 XHR requests are made to create the database with this sort of thing:

startData = { // data to find sub-data for here };

findData(startData);

function findData(data) {
for (var d in data) {
url = //obtained from data;
GM_xmlhttpRequest({
'method': 'GET',
'url': url + d,
'onload: getSubData(d);
});
}
}

function getSubData(d, response) {
// process response
// if subdata is found in response:
findData(d[subdata]);
}

(simplified, but hopefully you get the idea).

Since there can be many requests happening at the same time, I need to figure out a way of finding out when the last request has finished, so I can display a "finished" message and then store the data on the user's computer.

How can I go about this? I suspect this is something to do with onreadystatechange, but I don't know what to do with it.

 
Apr 30, 2007
Raffles 13 posts

Topic: Script development / Close the window?

Why do you want to do this if people can close windows by themselves? I don't think it can be done.