URL box/custom javascript

General questions about scripts and buttons should be asked here. Development scripts and buttons may also be posted for feedback.

Moderators: Support Staff², Support Staff, AvantGuard, Developer

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

URL box/custom javascript

Post by cApNhOwDy » Mon Aug 18, 2008 11:42 pm

javascript:(function(){var blackify;{blackify=document.createElement('link');blackify.rel='stylesheet';blackify.href='http://www.jabago.com/tools/CSS/blackif ... (blackify);}})();

So I found this code on the internet, and when I go to a website like google.com and then copy/paste this code into the URL box and press enter, it "blackifies" the page. I like this because it's easier on my eyes. I was wondering if there was a way to make this code go into effect for every website I visit?

bigC
AvantGuard
AvantGuard
Posts: 7244
Joined: Thu Jan 30, 2003 10:40 pm
Windows Version: 10
Avant Version: 2016 Build 1
Default engine: Firefox
IE Version: 11
Skin: Crystal
Location: New York

Re: URL box/custom javascript

Post by bigC » Tue Aug 19, 2008 7:01 pm

Make it into an addon. Go to Tools > Avant Browser Options > Addons, select the Addon tab & click Add. Now type a name for the addon & choose Auto-execute script. Paste your code in the main area, click OK.

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Thu Aug 21, 2008 5:24 pm

Oooh goodie, I learned something new today then. However, I still cant get it to work, any ideas as to whether or not it might be because of the code? Otherwise, doing it manually works correctly every time.

bigC
AvantGuard
AvantGuard
Posts: 7244
Joined: Thu Jan 30, 2003 10:40 pm
Windows Version: 10
Avant Version: 2016 Build 1
Default engine: Firefox
IE Version: 11
Skin: Crystal
Location: New York

Re: URL box/custom javascript

Post by bigC » Thu Aug 21, 2008 7:02 pm

Try using this code,

Code: Select all

(function(){
  var blackify;
  {
    blackify=document.createElement('link');
    blackify.rel='stylesheet';
    blackify.href='http://www.jabago.com/tools/CSS/blackifyCSS.css';
    document.getElementsByTagName("head")[0].appendChild(blackify);
  }
}
)();

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Thu Aug 21, 2008 8:49 pm

Oh my god dude, you rule so much. This works great.

bigC
AvantGuard
AvantGuard
Posts: 7244
Joined: Thu Jan 30, 2003 10:40 pm
Windows Version: 10
Avant Version: 2016 Build 1
Default engine: Firefox
IE Version: 11
Skin: Crystal
Location: New York

Re: URL box/custom javascript

Post by bigC » Thu Aug 21, 2008 10:03 pm

Pleasure to be of service. :D

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Mon Aug 25, 2008 12:06 am

So I know it's not your code or anything, but is there by chance a way to make exceptions for certain websites? I love the black overlay on all websites except for my online blog and digg.com, it doesnt work on those two websites in particular.

bigC
AvantGuard
AvantGuard
Posts: 7244
Joined: Thu Jan 30, 2003 10:40 pm
Windows Version: 10
Avant Version: 2016 Build 1
Default engine: Firefox
IE Version: 11
Skin: Crystal
Location: New York

Re: URL box/custom javascript

Post by bigC » Mon Aug 25, 2008 9:18 pm

I think its possible, I'm not sure exactly how to go about it though. I'll move this to Scripts and Buttons Development and Discussions, maybe someone better with javascript can edit the script for you...

User avatar
sulpherdragon
Contributor
Contributor
Posts: 222
Joined: Sat Dec 15, 2007 9:51 pm
Windows Version: Windows 7
Avant Version: 2013 Build 23
Default engine: Firefox
IE Version:
Skin:
Contact:

Re: URL box/custom javascript

Post by sulpherdragon » Mon Aug 25, 2008 11:47 pm

Trick is to create an array of strings for the plugin to check against

Code: Select all

var exceptionSite=new Array()

//change this to true if you wish to ignore exceptions completely

noExceptions=false;


//exceptionlist: add exceptions in the following format;

exceptionSite[0]="avant"
exceptionSite[1]="google"
exceptionSite[2]="wikipedia.org"






//code
runcode=true;

for (loop=0;loop<exceptionSite.length;loop++)
{
  if ((document.location.href.indexOf(exceptionSite[loop])>0 )&&(noExceptions==false))
  {
  runcode=false;
  }
}

if (runcode)
{
black()
}

function black()
{
  var blackify;
  {
    blackify=document.createElement('link');
    blackify.rel='stylesheet';
    blackify.href='http://www.jabago.com/tools/CSS/blackifyCSS.css';
    document.getElementsByTagName("head")[0].appendChild(blackify);
  }
}
This code checks the url for the peices of text in the exceptionSite list. that means you can be as vague as ".com" or as specific as "http://forum.avantbrowser.com".
Change the noExceptions if you wish to ignore them completely.

Plugin attached below, if you guys thing this should go in the releases section aswell we can stick it in there.
Attachments
Blackify.aba
Exactly what I specified in the code above.
(1.04 KiB) Downloaded 297 times
Image

abfan123
Avantus Maximus
Avantus Maximus
Posts: 5624
Joined: Wed Jan 26, 2005 4:24 pm
Windows Version: Vista Ultimate x64 SP2
Avant Version: 11.7 build 43
IE Version: 8
Contact:

Re: URL box/custom javascript

Post by abfan123 » Mon Aug 25, 2008 11:50 pm

You may try to check the location.hostname to disable it for the whole domain.
For example:

Code: Select all

if(location.hostname!="digg.com" && location.hostname!="myblog.com"){
  var blackify;
    blackify=document.createElement('link');
    blackify.rel='stylesheet';
    blackify.href='http://www.jabago.com/tools/CSS/blackifyCSS.css';
    document.getElementsByTagName("head")[0].appendChild(blackify);
  }
(Change myblog.com with your blog's domain)

EDIT
sulpherdragon has posted a more advanced & better script....
IE8(Pro), Microsoft Security Essentials
Main PC:
Image
Secondary PC same as primary but with Windows 7 x64 Ultimate as the OS.

User avatar
André
Administrator
Administrator
Posts: 5787
Joined: Sat Dec 14, 1901 3:19 am
Windows Version: Windows 7 x64
Avant Version:
Location: Baltimore and McHenry, Maryland, USA
Contact:

Re: URL box/custom javascript

Post by André » Mon Aug 25, 2008 11:57 pm

Damn. While I was working on this, two... TWO people post how to do it. I'm just too slow around here.
Formerly known as DrDrrae.
Image
I am not a member of the development team.
Please search the forum before posting questions.

Avant Force Wiki || Avant Force Blog
Desktop:
Intel C2Q Q9550 @ 3.7GHz || 8GiBs DDR2 800 @ 435MHz || Asus P5E
112 GiB SSD || 931 GiB HDD || 2x ATI 5770 in CrossfireX || Picture

NetBook:
ASUS Eee PC 1000HE || 1.66 GHz Atom N280 || 2 GiB DDR2 667 || 320 GiB HDD

NAS:
Intel E5200 @ 2.632 GHz || 4 GiB DDR2 800 @ 421 MHz || Foxconn G31MXP-K
5.45 TiB RAID 6

abfan123
Avantus Maximus
Avantus Maximus
Posts: 5624
Joined: Wed Jan 26, 2005 4:24 pm
Windows Version: Vista Ultimate x64 SP2
Avant Version: 11.7 build 43
IE Version: 8
Contact:

Re: URL box/custom javascript

Post by abfan123 » Tue Aug 26, 2008 12:08 am

DrDrrae wrote:Damn. While I was working on this, two... TWO people post how to do it. I'm just too slow around here.
And I've realized that I've wasted 2-3 minutes of my time :lol:

In fact, I first wanted to write a script that is similar to the sulpherdragon's script, But then decided to write something very simple because the OP just wanted to add 2 URLs....
So I'm glad that I've not wasted few more minutes... Oh, Wait, I've just wasted them writing this post. :oops: :lol:
IE8(Pro), Microsoft Security Essentials
Main PC:
Image
Secondary PC same as primary but with Windows 7 x64 Ultimate as the OS.

User avatar
sulpherdragon
Contributor
Contributor
Posts: 222
Joined: Sat Dec 15, 2007 9:51 pm
Windows Version: Windows 7
Avant Version: 2013 Build 23
Default engine: Firefox
IE Version:
Skin:
Contact:

Re: URL box/custom javascript

Post by sulpherdragon » Tue Aug 26, 2008 12:17 am

Gotta admit, that was weird realising two other people were doing the same thing at the same time.
Image

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Tue Sep 02, 2008 5:18 am

Wow, this community owns, honestly wasnt expecting any responce but I get more than what I ever bargained for. I only need to add 2 websites as exceptions at the time, I'm discovering more websites everyday that dont work well with the script so I decided to ask for an example of code that has more than one exception on it so that I could copy/paste code and figure out how to add more myself. Thanks bundles for everyone's help.

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Tue Sep 02, 2008 5:36 am

Hmmm, I'm trying out sulpherdragon's code, and there's a minor problem. The code doesnt work unless I visit the webpage and then refresh that webpage. I think that means that the code has to see that the URL is already in the URL box before it can make changes to that specific URL.

User avatar
sulpherdragon
Contributor
Contributor
Posts: 222
Joined: Sat Dec 15, 2007 9:51 pm
Windows Version: Windows 7
Avant Version: 2013 Build 23
Default engine: Firefox
IE Version:
Skin:
Contact:

Re: URL box/custom javascript

Post by sulpherdragon » Wed Sep 03, 2008 4:50 am

Code works fine for me, it only takes effect after the page has finished loading. Thats the same with all auto-exec scripts in avant though. If for some reason there is a javascript error on the page, it wont continue parsing the code in the plugin and the plugin wont work on the page.

Also there are 3 examples of exceptions in the code. Simple edit the plugin in avants options and add extra lines you want.

exceptionSite[0]="avant"
exceptionSite[1]="google"
exceptionSite[2]="wikipedia.org"
exceptionSite[3]="yahoo"
exceptionSite[4]="digg.com"
...

Anyone else having this problem?
Image

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Wed Sep 03, 2008 3:57 pm

Well I was testing it with Google, and got the same results everytime. First time I'd type in google.com, I'd get the black background. But if I refreshed the page, then white background. I dont know what the problem could be then.

Also, how come on some of the exception sites you have .com at the end of the name but on others you dont need it? Does it make a difference?

abfan123
Avantus Maximus
Avantus Maximus
Posts: 5624
Joined: Wed Jan 26, 2005 4:24 pm
Windows Version: Vista Ultimate x64 SP2
Avant Version: 11.7 build 43
IE Version: 8
Contact:

Re: URL box/custom javascript

Post by abfan123 » Wed Sep 03, 2008 5:04 pm

Auto-execute scripts doesn't work after a refresh. That's an old & apparently unfixed bug in Avant.
IE8(Pro), Microsoft Security Essentials
Main PC:
Image
Secondary PC same as primary but with Windows 7 x64 Ultimate as the OS.

cApNhOwDy
Newbie
Newbie
Posts: 20
Joined: Thu May 01, 2008 6:33 am
Windows Version: XP Pro
Avant Version: current
IE Version: 6

Re: URL box/custom javascript

Post by cApNhOwDy » Wed Sep 03, 2008 8:35 pm

That's wierd, because from what I'm experiencing, your auto-exec script doesnt work until I refresh. Or it could mean that my Blackify script isnt working, since it's black until I refresh then it's white. In that case, (which it is, I just checked) I cant get your script to work correctly in the first place.

abfan123
Avantus Maximus
Avantus Maximus
Posts: 5624
Joined: Wed Jan 26, 2005 4:24 pm
Windows Version: Vista Ultimate x64 SP2
Avant Version: 11.7 build 43
IE Version: 8
Contact:

Re: URL box/custom javascript

Post by abfan123 » Wed Sep 03, 2008 8:42 pm

Just to make sure I'm understanding, You've added Google as an exception, But when you enter the Google website, It apply the black style and when you refresh it doesn't apply the style?
IE8(Pro), Microsoft Security Essentials
Main PC:
Image
Secondary PC same as primary but with Windows 7 x64 Ultimate as the OS.

Post Reply

Who is online

Users browsing this forum: No registered users