![]() ![]() |
I live in Dubai, U.A.E and my ISP (Etisalat) has blocked the the site hosting deviantart' stylesheets and javascripts .. ie.(http://st.deviantart.net/). I thought i'd create a greasmonkey script that will point to the js/css hosted on my servers.. Im no good with javascript.. Can anyone help me out with writing the code for replacing the location of the stylesheet? or even whereever http://st.deviantart.net occurs change to http://myserver.com |
![]() ![]() |
I figured out how to do a find and replace.. How do you load the entire HTML contents of a page as a text string? |
![]() ![]() |
haden wrote: document.body.innerHTML |
![]() ![]() |
Replacing the href's: var hrefs = document.evaluate("//*[starts-with(@href, 'http://st.deviantart.net')", document, null, 6, null), href;
for(var i = hrefs.snapshotLength - 1; i>=0; --i) {
href = hrefs.snapshotItem(i);
href.href = "http://myserver.com" + href.href.substring(24);
}
|
![]() ![]() |
Avindra Gool... wrote:Bro, do this instead, no comparing to 0 and it's shorter: for(var i=0,item; (item=array.snapshotItem(i)); i++) {
// use item.href
}
|
![]() ![]() |
Thanks guys. That worked out.. |
![]() ![]() |
Hi guys.. Ive tried out your code.. It works for css/js links to.. But i need to replace deviantart.net to deviant.com where it occurs on the entire page.. That includes inside javascript code, img links etc..
|
![]() ![]() |
haden wrote: var array=document.evaluate("//a[contains(@href, 'deviantart.net')]",document,null,6,null);
for(var i=0,item; (item=array.snapshotItem(i)); i++) item.href=item.href.replace("deviantart.net", "deviantart.com");
|
![]() ![]() |
I forgot to mention that i had to change the src of images. Anyway i figured it out.. I got the script working. Thanks guys.. |

