Recent posts by sizzlemctwizzle
|
Jun 12, 2008
|
Topic: Script development / Modify DOM? To create an element you use |
|
Jun 3, 2008
|
Topic: Script development / regexp strip body Yeah, good point indeed. I always thought that the only functions using regexes were match, replace, exec and test. What other functions can use those?You can use a regexp with split also. And leaving the trailing body and html close tags will break the DOMParser. |
|
Jun 1, 2008
|
Topic: Script development / regexp strip body Have you tried?
|
|
May 29, 2008
|
Topic: Script development / domparser fun I loss the original code for the child loop. Mostly my errors occurred with the child loop. Not all the elements were being returned. |
|
May 29, 2008
|
Topic: Script development / domparser fun I use to use the domparser for one of my scripts thinking it would be easier but I encounter so many problems and errors all the time I just decided to start using Regexp. I find that it is much easier. I wish the domparser would work without having to serialize the document first. Btw if you care to know I did invent of way of getting innerHTML to work with the domparser. You simply loop through all the childnodes of an element serializing them and appending them to a string. |
|
May 23, 2008
|
Topic: Script development / Waiting for new window to load prevent embedded scripts from loading? No. |
|
May 23, 2008
|
Topic: Script development / Ajax calls userscript Why would you need to send anything to a server with greasemonkey? |
|
May 23, 2008
|
Topic: Script development / domparser fun You need to define a function before you can use it. put get("http://google.com"); at the bottom of the script. I decide to just rewrite your script
function $(item) {return document.getElementById(item);}
function cb(html) {
$('text').innerHTML = html.split(/<body[^>]*>((?:.|\n)*)<\/body>/i)[1];
var p = new DOMParser();
var xs = new XMLSerializer();
var doc = p.parseFromString(xs.serializeToString($('text')), "text/xml");
var dev = document.evaluate('//IMG', doc, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
$('text').innerHTML = dev.snapshotItem(0).getAttribute('src') + ' and ' + dev.snapshotLength;
}
function get(url) {
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(xhr) { cb(xhr.responseText); }
});
}
get("http://www.google.com/");
|
|
May 22, 2008
|
Topic: Script development / Waiting for new window to load How about an eventlistener?
winNew = window.open('http://userscripts.org');
winNew.addEventListener('DOMContentLoaded' instead',function () {
getDiv = winNew.document.getElementById("Some_ID");
if (getDiv != "undefined") {
... extract data
}
},false)
Edit: Yeah thanks Mikado it should be DOMContentLoaded |
|
May 22, 2008
|
Topic: Script development / Save and Get a value?
|
|
May 21, 2008
|
Topic: Script development / Getting source of current script Yeah I've searched it a lot and I think your right. |
|
May 21, 2008
|
Topic: Script development / Getting source of current script Thanks Mikado! But when I use |
|
May 20, 2008
|
Topic: Script development / Getting source of current script Okay, so what I want to do is read the greasemonkey metadata of the current script. I know that all greasemonkey scripts are encapsulated in an anonymous function to prevent scripts from interacting with each other. Because the function is anonymous it is almost impossible to reference it. I have tried the parent keyword but that only gives me the window object because that is the function's constructor. Can anyone give me a way that I could accomplish this? |
|
May 19, 2008
|
Topic: Script development / Problem gathering XML data Replace the respective lines with this.
var itemLink = root[i].getElementsByTagName('link')[0].nodeValue;
var itemName = root[i].getElementsByTagName('title')[0].nodeValue;
var itemDate = root[i].getElementsByTagName('pubDate')[0].nodeValue;
That should fix it all. |
|
May 19, 2008
|
Topic: Script development / GM_xmlhttpRequest set cookie
GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
'User-agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11',
'Accept': 'application/atom+xml,application/xml,text/xml',
'Cookie': '__utmz=something; __utma=something'
},
onload: function(xhr) { cb(xhr.responseText); }
});
|
|
May 19, 2008
|
Topic: Script development / Problem gathering XML data
|
|
May 11, 2008
|
Topic: Script development / Unlock and view any private Myspace profile and photo by scripts There's no way to do this unless you found some security hole in myspace, but I doubt she's your daughter anyway. |
|
May 11, 2008
|
Topic: Script development / replace a function for use by a page's code
|
|
May 10, 2008
|
Topic: Script development / Using jQuery library with Greasemonkey Personally I hate using huge libraries. I only like including functions in my scripts that I actually need. Quit being lazy and write scripts yourself. |
|
May 7, 2008
|
Topic: Script development / replace a function for use by a page's code @Aquilax xmlhttpRequests returns plain text, which means that javascript functions are never evaluated. It doesn't really matter whether or not the page is cached. That only mattered in a script of mine which automatically reloaded parts of a page. |
|
May 5, 2008
|
Topic: Script development / replace a function for use by a page's code If I remember right if you xmlhttprequest the same page you are on you get a cached version of the page. This is probably unimportant for this script but since I took this code out of one of my scripts I naturally forgot to omit that line. Your code will probably work aswell. |
|
May 4, 2008
|
Topic: Script development / Storing JavaScript Objects @Aquilax
|
|
May 4, 2008
|
Topic: Script development / replace a function for use by a page's code The way I came up with is fucking crazy and really hacky, but its the only way you can be sure. Plus it forces you to load the same page twice.
// ==UserScript==
// @name substitute that function
// @namespace tag:fooblarg,2008-05-02:subst-func
// @description Replaces an annoying function
// @include http://site.tld/*
// @include http://*.site.tld/*
// ==/UserScript==
function XHR(url) {
GM_xmlhttpRequest({
method: 'GET',
url: url,
headers: {
'User-agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11',
'Accept': 'application/atom+xml,application/xml,text/xml',
},
onload: function(responseDetails) {
body = responseDetails.responseText.split(/<body[^>]*>((?:.|\n)*)<\/body>/i)[1];
document.body.innerHTML = body;
});
}
function get_url() {
if (self.location == top.location) { //Make Sure this doesn't preform in an iFrame
url = window.location.href;
if (window.location.hash != null) {
url = url.split('#')[0];
}
var url = url + "#refresh";
return url;
} else {
return false;
}
}
url = get_url();
if (url != false) {
window.location.assign(void(window.annoying=function(){return true;}));
XHR(url);
}
|
|
May 4, 2008
|
Topic: Script development / DIG 4.8. getElementByClassName inserd of getElementById damn I can't wait for firefox 3 to roll out. it really doesn't matter though because it would mean forcing users to update first before they can use your script. here's a little function though. I'm having problems getting it to work with the XPCNativeWrapper. Can anyone help me out?
document.getElementsByClassName = function(className) {
var wrapper = new Array();
for (var dev = this.evaluate('//*[@class="'+className+'"]', this, null, 6, null), i = 0, div; div = dev.snapshotItem(i); i ++) {
wrapper.push(div);
}
return wrapper;
}
elements = document.getElementsByClassName("YOUR_CLASS_NAME");
|
|
May 4, 2008
|
Topic: Script development / replace a function for use by a page's code maybe use xpath and innerHTML to replace the function called by the page with your own code. or if the script tag is hard to get with xpath you could use Regexp and replace. |
