...

View Full Version : Greasemonkey - Hide links with JavaScript



JakeWatkins
08-20-2007, 01:28 AM
I thought it was


(function() {

// document.getElementById("meebolinks").style.display = "none"
document.getElementById("meebologo").style.display = "none"
document.getElementById("languagelinks").style.display = "none"
document.getElementById("copyright").style.display = "none"
document.getElementByTitle("about").style.display = "none"

})();

And the getElementById works.. but not the getElementByTitle doesn't. If anyone is aware of meebo.com please let me know! = )

kosstr12
08-20-2007, 09:48 PM
Is this by any chance for taking away the links/copyrights/info about the site that your subdomain that your site is hosted on?:cool:

JakeWatkins
08-20-2007, 10:13 PM
It's not really mine. But it is to hide certain links on a page, yes. Any help, guys?

LFCFan
08-21-2007, 03:18 PM
There's no such thing as 'getElementByTitle'. If you are trying to hide the title of the page (the part that appears in the top of the window) then this should do it:

window.title = ""

It will not work though if you don't own the rights to the page you are trying to alter.

If you own the page and there is an element with the id of title, then you should change the id as 'title' is reserved as part of the window model. Then you can use getElementById till your hearts content.

Cheers
Joe

JakeWatkins
08-23-2007, 02:09 AM
Is there anyway I can hide individual links though?

felgall
08-23-2007, 03:28 AM
It will not work though if you don't own the rights to the page you are trying to alter.

Greasemonkey scripts run in the browser and not the web page and so you can do what you like to anyone's page regardless of how they have their page set up- only you will see it though.

You could set up a loop using the getElementsByTagName('a') array to process all the links on the page and hide them all or test their innerHTML or attributes to work out which to hide. Still not sure why you want to hide specific links on certain web pages in your web browser though. Ignoring the links would be easier.

fruitwerks
08-23-2007, 12:41 PM
I have a handy little script that will hide links on a mouse over if that is what you were looking for...

http://sweetskies.fruitwerks.us/hidelinks.js

JakeWatkins
08-24-2007, 01:47 AM
Still not sure why you want to hide specific links on certain web pages in your web browser though. Ignoring the links would be easier.

Well if you've ever used meebo then you should know of the space they give you. I like it, a lot! So when put up to the issue, I decided only needing some links that I use it better than nothing :p

JakeWatkins
08-24-2007, 01:57 AM
Greasemonkey scripts run in the browser and not the web page and so you can do what you like to anyone's page regardless of how they have their page set up- only you will see it though.

You could set up a loop using the getElementsByTagName('a') array to process all the links on the page and hide them all or test their innerHTML or attributes to work out which to hide. Still not sure why you want to hide specific links on certain web pages in your web browser though. Ignoring the links would be easier.

I'm not 100% sure on how to do that, I mean don't get me wrong, it sounded pretty, and like it would work, but I really don't know much about JavaScript heh

felgall
08-24-2007, 02:54 AM
Take a look at the two scripts I have at http://javascript.about.com/library/blimgd.htm

One removes all the image tags completely from a page while the other simply hides them. You would just need to do something similar but for the <a> tags instead of the <img> tags

fruitwerks
08-29-2007, 12:23 AM
my bad, I actually moved my java over the day I posted this - I see hits for it so the NEW url is http://sweetskies.fruitwerks.us/js/hidelinks.js


I have a handy little script that will hide links on a mouse over if that is what you were looking for...

http://sweetskies.fruitwerks.us/hidelinks.js



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum