GreaseMonkey help? Need help fixing specific dead links on a forum.

balloonshark

Diamond Member
Jun 5, 2008
7,132
3,615
136
I'm a member on a forum that recently updated its phpbb version. For some reason the upgrade killed all of the old forum links. The admin says it can't be fixed or has no time or interest in fixing the issue.

Here is what a new working link looks like.
http://www.forumname.com/viewtopic.php?f=43&t=14423

Here is what a broken link looks like.
http://www.forumname.com/forum/viewtopic.php?t=1496

All that needs to be done is remove the /forum part of the link. Can this be done with GreaseMonkey or other add-ons? Can you help me with a fix for the users? Will the fix affect other forums?

P.S. This is not not my forum. I'm just a forum helper.
 
Last edited:

lxskllr

No Lifer
Nov 30, 2004
60,003
10,489
126
That can definitely be done with GreaseMonkey, and it should be trivial to accomplish. Unfortunately, I don't know js, and I haven't found a script I can use directly yet. It'll only affect as much as you want it to. Scripts can be setup for a single page, or every page on the web.

Here's a search to get you started...

https://duckduckgo.com/?q=replace+links+user+script+greasemonkey

You'll have to do some work. I don't think you'll find exactly what you want, but you may find something close enough you can easily modify to your needs.

You might find this helpful also...

http://www.scribd.com/doc/15491073/Greasemonkey-Hacks-Tips-Tools-for-Remixing-the-Web-with-Firefox
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,695
4,657
75
Yes, that should be easy. Let me outline the Greasemonkey code:

Code:
var links = document.getElementsByTagName('A');
for(var i=0; i < links.length; i++) {
  var spos = links[i].href.indexOf('/forum/');
  if(spos >= 0) {
    links[i].href = links[i].href.substring(0,spos+1) + links[i].href.substring(spos+7);
  }
}

That might work, but I haven't tested it - in part because you didn't give me a real site address. Exclusions for links to sites that aren't this site might also be useful.

There are also lots of Greasemonkey scripts in [thread=2019367]this thread[/thread].
 

balloonshark

Diamond Member
Jun 5, 2008
7,132
3,615
136
Thanks for your replies. I'm afraid I also don't know js. I don't even have GreaseMonkey installed at the moment. I just knew it could modify web pages.

Here is a link to a sticky on the site. http://www.microtforum.com/viewtopic.php?f=19&t=7246

The very first link in that sticky is one example of what needs fixed. Just the /forum part needs removed from any http://www.microforum.com links

All links similar to this http://www.microtforum.com/forum/viewtopic.php?t=1496 need to be http://www.microtforum.com/viewtopic.php?t=1496 in order to work properly.