Golanlan Posted August 26, 2006 Share Posted August 26, 2006 Let's say I've got a link with this source: <a href="http://register.meow.com">Register</a> how can I remove this link from the page? It's should be with HTML DOM, to all of you who doesn't know greaseMonkey. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 28, 2006 Share Posted August 28, 2006 What about greaseMonkey? Is it a browser, or a language?With javascript that link can easily be removed from a page, but you should target its parent to get the element form the DOM structure. Or add an ID attribute, but if you want to remove it by script, then adding an attribute would not be a sollution :)Could you post the code that this link is in, so we can target it with script? Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 var links = document.getElementsByTagName('a');for(i=0;i<links.length;i++){ if(links[i].innerText == "Register") links[i].style.display = "none";} Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 28, 2006 Share Posted August 28, 2006 Of cource, but what when various links contain the same text, but only one should be removed? Its better to safely target the link, to obsolete an array Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 that is true...you should give you links ids so you can target a specific one Link to comment Share on other sites More sharing options...
Golanlan Posted August 28, 2006 Author Share Posted August 28, 2006 I wish to remove the "Watch this deviant!" from http://golanlan.deviantart.com/ , using GreaseMonkey extension for firefox, that uses DOM for it's actions.aspnetguy, the script isn't working.. I guess you should had look at the source before writing this. sorry. Link to comment Share on other sites More sharing options...
Jack McKalling Posted August 28, 2006 Share Posted August 28, 2006 var links = document.getElementById('deviant-commands');links.getElementsByTagName('a')[0].style.display = "none";And this goes at the end of the body inside a script element Link to comment Share on other sites More sharing options...
aspnetguy Posted August 28, 2006 Share Posted August 28, 2006 I wish to remove the "Watch this deviant!" from http://golanlan.deviantart.com/ , using GreaseMonkey extension for firefox, that uses DOM for it's actions.aspnetguy, the script isn't working.. I guess you should had look at the source before writing this. sorry.Doesn't matter what your source is if you place this in <script></script> tags as the last thing before </body> it will work....it filters out and link with the text Register as a label. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now