Recent posts by dob

Subscribe to Recent posts by dob 248 posts found

Aug 29, 2008
dob 248 posts

Topic: Script development / Post form on Blog.ru

english, buddy :-)

 
Aug 25, 2008
dob 248 posts

Topic: Userscripts.org discussion / Spam and malware

Yeah, maybe you'll be captcha'd for your first two threads or so?

 
Aug 25, 2008
dob 248 posts

Topic: Userscripts.org discussion / Spam and malware

What's your position on Captchas, Jesse?

 
Aug 23, 2008
dob 248 posts

Topic: Userscripts.org discussion / Spam vs. Topics 616:85

I'm assuming they have some sort of bot viewing the thread to keep it on the first page?

 
Aug 23, 2008
dob 248 posts

Topic: Script development / GM_setValue problem...

I once tried to write a script that automatically enables you to store objects and functions and so on with GM_getValue(), and also it will return a object if what is stored looks like it.
I never tested it but it was something like this:

var _GM_getValue = GM_getValue, _GM_setValue = GM_setValue;
function GM_getValue(what) {
	switch((typeof eval(_GM_getValue(what))).toLowerCase()) {
		case "object": return new Object(eval(_GM_getValue(what)));
		case "function": return new Function(eval(_GM_getValue(what)));
		case "string": return new String(_GM_getValue(what));
		case "number": return parseInt(_GM_getValue(what));
		case "undefined": try {
					return new String(_GM_getValue(what));
				} catch(e) {
					return null;
				}
	}
}

function GM_setValue(what) {
	switch((typeof what).toLowerCase) {
		case "object": _GM_setValue((new Object(what)).toString()); return;
		case "function": _GM_setValue((new Function(what)).toString(); return;
		case "string": _GM_setValue(new String(what)); return;
		case "number": _GM_setValue(what); return;
		case "undefined": _GM_setValue(new String(what));
	}
}	

 
Aug 8, 2008
dob 248 posts

Topic: Script development / HTTP methods

You could use something like this to read out the methods and do something about it:

if (GM_getValue("method") == "") {
	GM_setValue("method", "nothing");
}
var forms = document.evaluate("//form[@method]", document, null, 6, null), i, form, method = GM_getValue("method");
for (i=0; i<forms.snapshotLength; i++) {
	form = forms.snapshotItem(i);
	form.addEventListener("click", function(e) {
		e.preventDefault();
		e.stopPropagation();
		GM_setValue("method", this.method.toLowerCase());
		this.submit();
	}, false);
}

if (method == "post") {
	// do something with POST
} else if (method == "get") {
	// do something with GET
} else {
	GM_log("Couldn't read method");
}

 
Aug 7, 2008
dob 248 posts

Topic: Script development / document.selection is undefined

I like using this function, it also selects the text:

function addtext(tag, text) {
	var tag1 = "["+tag+"]", tag2 = "[/"+tag+"]",
		ta = document.getElementsByTagName("textarea")[0],
		start = ta.selectionStart,
		end = ta.selectionEnd;
	ta.focus();
	ta.value = ta.value.substring(0, start) + tag1 + text + tag2 + ta.value.substring(end);
	ta.selectionStart = (ta.value.substring(0, start) + tag1).length;
	ta.selectionEnd = ta.selectionStart + text.length;
}

addtext("img", "IMAGEURI");

 
Aug 6, 2008
dob 248 posts

Topic: Script development / block infinite alerts

Well apparently GM doesn't work on local files, I only tried it with that.
Anyway, thanks for the answer, but I prefer the confirm() solution :p

 
Aug 5, 2008
dob 248 posts

Topic: Script development / block infinite alerts

Hello,
as you all know, a simple while(true)alert("foo"); will pretty much crash almost every browser (you just can't do anything else).
Opera has a real nice feature to block that, but Firefox does not.
So what I found is this: http://userscripts.org/scripts/show/11959

But it doesn't work for me.
I'm using GM 0.8.20080609.0, and the script is on first place in the list.

Any ideas?
Or even better, some other satisfying solution?

 
Aug 5, 2008
dob 248 posts

Topic: Userscripts.org discussion / More script metadata exposed

Shouldn't that go without saying?
I mean if I don't want people to use my code, I'll hardly post it here, or at the very least I'd obfuscate it...

 
Aug 5, 2008
dob 248 posts

Topic: Script development / calling javascript injected into page body

Guys, you might want to look into unsafeWindow on the Greasespot Wiki.
It's by far the easiest way:

unsafeWindow.pop = function(url) {
  newWin = window.open(url, "vid"...);
}

 
Aug 3, 2008
dob 248 posts

Topic: Userscripts.org discussion / Spam and malware

Spammer: http://userscripts.org/users/61710

 
Aug 2, 2008
dob 248 posts

Topic: Ideas and script requests / adding a search button to google

That's very well possible.
You can add as many search engine buttons as you want, all you need to tell us is the action attribute of your search forms.

 
Aug 1, 2008
dob 248 posts

Topic: Script development / questions about document and automatic script disabling

vhaerun wrote:

Hello guys !

I'm pretty new to greasemonkey , and I would like to ask the following questions :

1. if i use GM_xmlhttprequest , how could i access the requested page's document? I'm trying to use an xpath expression to parse the page , and so far , if i try to access the document , i'm accessing the current's page document.

The way I do it: GM_xmlhttpRequest({   method: "get",   url: "site.php",   onload: function(t) {    var text = e.responseText, parser = new DOMParser();    var html = parser.parseFromString(text, "text/xml");    alert(html.getElementsByTagName("div")[0].textContent);   } });
 
Jul 29, 2008
dob 248 posts

Topic: Userscripts.org discussion / Disappeared topic

Maybe they'd like you post your suggestion on uservoice.com.

 
Jul 28, 2008
dob 248 posts

Topic: Script development / How to click the login button?

I'd go with the first one, xpath is not implemented in IE, just in case there are any IE users.

 
Jul 28, 2008
dob 248 posts

Topic: Script development / Getting previous node

var font = document.evaluate("//font[contains(@class, 'mini')]", document, null, 6, null), i;
for (i=0; i<font.snapshotLength; i++) {
    font.snapshotItem(i).style.display = "none";
}

 
Jul 23, 2008
dob 248 posts

Topic: Script development / Facebook Ad AJAX update killer

Just for the record:
Execute a function every X seconds: window.setInterval(function() {}, X);

 
Jul 23, 2008
dob 248 posts

Topic: Script development / How to use variables set by inline js

var my_var = unsafeWindow.their_var

Works with Variables, Functions, Objects and so on.

 
Jul 22, 2008
dob 248 posts

Topic: Script development / Help with smiley replacement?

Mikado used to have a script for that, but it seems offline.
Since there is no way of contacting ppl through PMs, I took the liberty of pasting it: http://o0t.de/nopaste/paste.php?f=jbjhvx

 
Jul 22, 2008
dob 248 posts

Topic: Script development / Facebook Ad AJAX update killer

Let's say your script has the function removeads()
Ususally, you could just do this:

function removeads() {
// code
}
removeads();
document.addEventListener("DOMNodeInserted", removeads, true);

But since there seems to be a bug, just do this:
function removeads() {
// code
}
window.setTimeout(function() {
  removeads();
}, 3000);

That means that your code and the function will be executed after 3 seconds.

 
Jul 21, 2008
dob 248 posts

Topic: Script development / xpath

Thank you. :)

 
Jul 20, 2008
dob 248 posts

Topic: Script development / xpath

Hello everyone,

I'd love some help with an xpath problem.

This is the code I am working with:

<div id="bx_frndsBday_bx_tg">
	<div class="moveBoxSub">stuff</div>
	<div class="moveBoxCont">
		<dl class="teaserList1">
			<dt>
				<a class="teaserPic" href="showHome.do?accountId=123">link</a>
			</dt>
		</dl>
	</div>
</div>

It's just shortened, the actual code can be found here, and in action here

And this is my XPath so far:

var box = $x("//div[@id='bx_frndsBday_bx_tg']/div[@class='moveBoxCont']/dl[@class='teaserList1']/dt/a[contains(@href, 'showHome.do?accountID=')]");
alert(box[0].innerHTML);

I use the $x function.
Well, it kind of makes sense to me, but I get an empty array back, so I thought some of you might be able to help me.

Thanks! :)

 
Jul 17, 2008
dob 248 posts

Topic: Script development / How can I change all links style?

Check out stylish addon.

 
Jul 16, 2008
dob 248 posts

Topic: Script development / how can I destroy all iframes?

Exactly, Firefox knows how to handle forEach and HTMLCollections.