Recent posts by psyched

Subscribe to Recent posts by psyched 157 posts found

Mar 6, 2008
psyched 157 posts

Topic: Ideas and script requests / How do you install a scipt?

paulfrottawa wrote:

PS: I installed greasemonkey

That's good. Well what you're looking for is a script that creates containers with said site in em. The easiest way I believe would be an iframe, but that doesn't look nice and has a bunch of issues. Or do you actually want to watch the videos? There are several scripts that can embed videos from a link on the site you're visiting, for example you read a youtube.com link somewhere in a page, the script will make the video appear on the webpage.
 
Mar 6, 2008
psyched 157 posts

Topic: Ideas and script requests / How do you install a scipt?

What?

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / select text within a div

Mikado wrote:

I meant it's 7.4 seconds for that one million loop, so no need to take an average.

Sure, whatever :o
 
Mar 5, 2008
psyched 157 posts

Topic: Userscripts.org discussion / IRC Channel

Hello,

is there such thing as an userscripts.org IRC Channel?
I believe it would be a nice thing do answer quick questions,
reducing all the useless threads and requests in the Forums.

Maybe anyone could run it on a server or something like that?

What do you guys think?

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / select text within a div

What for? That little copy script on my page runs in about 0.3 seconds (felt like that), so why even bother? Oo

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / select text within a div

Mikado wrote:

OK, I've tested some regexps with the following code:

var d = new Date(), re = REGEXP_HERE, t = '    \n\t test case \n newline  ' /* or just '    \n\t test case  newline  '*/, r;
for (var i = 0; i < 1000000; i++) r = t.replace(re, '' /* or $# */);
alert(new Date() - d + '\n_' + r + '_');

The winner for one-line strings is simplified Descriptor's /^\s*(.*?)\s*$/ with 7400ms , but line break kills it (tried playing with g and m flags, no luck). My helloworldy /^\s+|\s+$/g runs one second longer, but is insensitive to the line break.

Draw?

7400ms is 7.4 seconds, right? it doesn't quite take that long with mine :o
 
Mar 5, 2008
psyched 157 posts

Topic: Ideas and script requests / Address link type scripts, whats best?

I'd use an Addon like Linkification - much faster.

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / select text within a div

Certainly not something like


for (i<1000000)
...
Anyways, now I know, and it's all about learning =)

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / select text within a div

Again, how can I measure if a regex is faster than another?

 
Mar 5, 2008
psyched 157 posts

Topic: Ideas and script requests / How do you install a scipt?

Dive into Greasemonkey and Greasespot Wiki

 
Mar 5, 2008
psyched 157 posts

Topic: Ideas and script requests / Help Feed Rescued Animals!

Tools -> Greasemonkey -> New User Script
There you can add a namespace, all URLs the script should run on, and the ones you don't want it to run.

Simply copy&paste my code, and everything will be done

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / GM_openInTab() opens unlimited tabs

The script does indeed trigger on the tab, but the opened tab doesn't contain any links like that, it does have one on its url bar, though.
Still don't see why it keeps opening tabs then, it doesn't match anything there.

Weird, when I add an @exclude with the tabs URL, it works.

I really can't see why it does that.

 
Mar 5, 2008
psyched 157 posts

Topic: Script development / useful piece of code for GreaseKit 1.4

How is that better?
GM_addStyle() css strings have priority before all embedded stylesheets and such, pretty much like adding !important behind every rule, as far as I know..
But let me know why it's better ;)

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / select text within a div

Mikado wrote:

Wow, znerp`s regexp is 1.2 to 2 times faster than 2 simple replacements. Thanks for the tip.

How does one measure that? That regex doesn't trim anything, by the way.
 
Mar 4, 2008
psyched 157 posts

Topic: Ideas and script requests / Help Feed Rescued Animals!

setInterval(function() { window.location.refresh(); }, 1000);

That should do it, but it seems pretty weird to me.

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / select text within a div

Yeah, you're right. I won't change it, cuz it's already out, but it's cleaner this way.
AND looks cooler. :D

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / select text within a div

Yeah, it really was too easy...

String.prototype.trim = function() {
	return this.replace(/^\s+/, "").replace(/\s+$/, "");
}
function copy(value) {
	var code = value.trim();
	var swf = document.createElement("embed");
	swf.src = "copy.swf";
	swf.width = swf.height = 0;
	swf.setAttribute("flashvars", "clipboard="+encodeURIComponent(code));
	document.body.appendChild(swf);
}

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / useful piece of code for GreaseKit 1.4

W00t??
Why would anyone remove the thing that makes Greasemonkey/Greasekit adorable the most??

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / GM_openInTab() opens unlimited tabs

Nah, I just started working there :)
I write stuff all the time... Seriously, I have about 20 or so scripts that are completely useless for everyone else, but I couldn't live without them... ^^

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / GM_openInTab() opens unlimited tabs

I'm not too experienced with regexes, but I don't think it'd make any difference.
Thanks for the advice, though. I'll test it tomorrow when I'm at work again.
And yes, I do write GM scripts at work :-D

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / select text within a div

Guess what, I really tried that, too :O

All I could find out was that it sent some sort of request...
I never did anything with flash before, so I really have no idea what exactly "flashvars" does and so on...

You don't have to do it, of course, it's probably totally simple, but I've been doing way to much JS today, can't really get myself to look for ajax stuff in some addon anymore :P

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / GM_openInTab() opens unlimited tabs

Hey there,

I have the following code:


var links = document.getElementsByTagName("a");
for (var i=0; i<links.length; i++) {
	if (links[i].href.match(/listMembers\.do\?method=acceptAspirant/gi)) {
		GM_openInTab(links[i].href);
	}
}

The problem is, my Fox won't stop opening tabs. I seriously can't see why it does that, I'm pretty sure GM_openInTab should only trigger if the href matches my regex.

Anyways, I tried using an Array() then and pushing the links[i].href => same result: 1000 tabs.

If I GM_setValue() my links[i].href, later on split it into a new array and read my hrefs from that, again: 1000 tabs.

I think my Fox simply opens a tab for every single link found in that page, but that doesn't seem to make the slightest sense, since I actually test the links[i].href (and I'm positive it's the only one in there that matches the regex).

Adding a break; isn't an option, since I'll want the script to open up a couple of tabs and do stuff with the sites in these tabs.

So, is this my mistake or did I really find a GM Bug?

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / select text within a div

psyched wrote:

You are my hero. Thank you sooo much, man.

This userscript works really well, thanks again. Might sound like a silly question, but how would I use that as an embedded script on my own website? Nothing I tried so far has worked...
 
Mar 4, 2008
psyched 157 posts

Topic: Script development / GM_registerMenuCommand

I see what you mean, I had that same problem with using a links[i].href in a callback function for GM_xmlhttpRequest()...

I think I solved it using GM_setValue() and GM_getValue() - you can access these from anywhere in the script.

 
Mar 4, 2008
psyched 157 posts

Topic: Script development / GM_registerMenuCommand

Why so weird?



GM_registerMenuCommand("Name of Comman", function() {
 // your code here
});