Bookmarklet to convert old gamesquad urls to new

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
This is highly, HIGHLY kludgey, but it does seem to work (in the current Firefox, on linux). Using it is a PITA, but it is better than converting by hand.

To create the bookmarklet (in Firefox, on linux), go to your bookmarks toolbar, right-click, new bookmark.... Name can be whatever you like. The Location is (expand the quoted text, copy and paste):
javascript: (
function(){
var s=prompt('Enter URL','');
s = s.replace(/%253A/gi,':');
s = s.replace(/%252F/gi,'/');
s = s.replace(/%253F/gi,'\?');
var googleRE=/http:\/\/forums.gamesquad.com\/showthread.php\?([0-9]+)-/;
var gamesquadRE=/http:\/\/forums.gamesquad.com\/showthread.php\?t=([0-9]+)/;
var newGamesquadRE=/http:\/\/www.gamesquad.com\/xenforo\/index.php/gi;
var matchesFound=s.toLowerCase().match(googleRE);
if (!matchesFound ) {
matchesFound = s.toLowerCase().match(gamesquadRE);
};
if(matchesFound) {
window.open('http://www.gamesquad.com/xenforo/index.php?threads/'+matchesFound[1]);
}
else {
if ( s.toLowerCase().match(newGamesquadRE ) ) {
window.open( s );
}
else {
alert('Unable to match string as old gamesquad URL.');
}
};
})()
Save.

To use (in firefox, on linux), find a link with an old URL, right-click, copy link location. Click on the bookmarklet button you created above. It will prompt you for the old URL; paste it in. Click ok. A new window/tab should open with the page. If the script cannot match the string pasted to a gamesquad URL it understands (e.g. if you type in random characters), it will display a message saying it was unable to parse the string.

This works on my machine for URLs found in gamesquad posts (both old and new) and for URLs found on google.

IMPORTANT: THIS WILL NOT WORK FOR ATTACHMENTS. It will not work for old files. It will work for links to old threads only.

This is UNSUPPORTED. That means, if you have trouble with it on your machine or browser, you have to figure out why. I do not know how to add a bookmarklet to your Opera browser. I do not know which is the bookmark toolbar on your browser. I do not know why your machine opens up hundreds of windows for porn sites. You will have to figure it out.

As a possible clue, I will mention that firefox insists on URL-encoding the javascript. That means that I had to put the percent-sign in as "%25". If your browser does not URL-encode the javascript, you might try replacing "%25" with "%".

JR
 
Last edited:

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
The bookmarklet does not work on links from google marked "[archive]".

JR
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
I have modified the bookmarklet code so it should search items from google marked "[archive]". Use the directions above, but paste this code instead:

Code:
javascript: (
  function(){
    var s=prompt('Enter URL','');
    s = s.replace(/%253A/gi,':');
    s = s.replace(/%252F/gi,'/');
    s = s.replace(/%253F/gi,'\?');
    var googleRE=/http:\/\/forums.gamesquad.com\/showthread.php\?([0-9]+)-/;
    var googleArchiveRE=/http:\/\/forums.gamesquad.com\/archive\/index.php\/t-([0-9]+)/;
    var gamesquadRE=/http:\/\/forums.gamesquad.com\/showthread.php\?t=([0-9]+)/;
    var newGamesquadRE=/http:\/\/www.gamesquad.com\/xenforo\/index.php/gi;
    var matchesFound=s.toLowerCase().match(googleRE);
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(googleArchiveRE);
    };
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(gamesquadRE);
    };
    if(matchesFound) {
      var newURL = 'http://www.gamesquad.com/xenforo/index.php?threads/'+matchesFound[1];
      window.open( newURL );
    }
    else {
      if ( s.toLowerCase().match(newGamesquadRE ) ) {
        window.open( s );
      }
      else {
        alert('Unable to match string as old gamesquad URL.');
      }
    };
  })()
JR
 
Last edited:

Rock SgtDan

Senior Member
Joined
Nov 29, 2012
Messages
2,579
Reaction score
125
Location
State of Confusion
First name
Dan
Country
llSlovenia
>To use (in firefox, on linux), find a link with an old URL, right-click, copy link location. Click on the bookmarklet button you created above. It will prompt you for the old URL; paste it in.
>
What's a "bookmarklet?"
And this is for what? Converting existing bookmarks in your browser bookmark list? Going to a URL you find embedded in a Gamesquad post?
If the latter, then why can't the owner just run the script thru the website and convert all the URLs?

"Making a button ???"
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
I have updated the bookmarklet to the new-new gamesquad URLs. The bookmarklet will translate the old-new URLs as well as all the old URLs.

edit: this updated to 20170110 version
Code:
javascript:(
  function(){
    /* 20170110 */
    var baseNewUrl = 'http://www.gamesquad.com/forums/index.php?threads/';
    var s=prompt('Enter URL','');
    s = s.replace(/%253A/gi,':');
    s = s.replace(/%252F/gi,'/');
    s = s.replace(/%253F/gi,'\?');
    var googleRE=/http:\/\/forums.gamesquad.com\/showthread.php\?([0-9]+)-/;
    var googleArchiveRE=/http:\/\/forums.gamesquad.com\/archive\/index.php\/t-([0-9]+)/;
    var gamesquadRE=/http:\/\/forums.gamesquad.com\/showthread.php\?t=([0-9]+)/;
    var oldNewGamesquadRE=/http:\/\/www.gamesquad.com\/xenforo\/index.php\?[^.]+\.([0-9]+)/;
    var oldPostUrlRE = /http:\/\/forums.gamesquad.com\/showpost.php\?p=([0-9]+)/;
    var newGamesquadRE=/http:\/\/www.gamesquad.com\/forums\/index.php/;
    var matchesFound=s.toLowerCase().match(googleRE);
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(googleArchiveRE);
    };
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(gamesquadRE);
    };
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(oldNewGamesquadRE);
    }
    if ( !matchesFound ) {
      matchesFound = s.toLowerCase().match(oldPostUrlRE);
      if ( matchesFound ) {
        baseNewUrl = 'http://www.gamesquad.com/forums/index.php?posts/';
      }
    }
    if(matchesFound) {
      var newURL = baseNewUrl + matchesFound[1];
      window.open( newURL );
    }
    else {
      if ( s.toLowerCase().match(newGamesquadRE ) ) {
        window.open( s );
      }
      else {
        alert('Unable to match string as old gamesquad URL.');
      }
    };
  })()
JR
 
Last edited:

Srynerson

Senior Member
Joined
Jun 4, 2011
Messages
2,605
Reaction score
367
Location
Denver
Country
llUnited States
I would not be opposed to our forum overlords adding some redirects to the web site so that all this would occur "auto-magically." In the meanwhile this is an ok workaround.

JR
In the alternative, maybe this could be made a "sticky" post if that's still possible in the new software.
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
I found a type of old link I had not seen before, a link that goes directly to a post (e.g. http://forums.gamesquad.com/showpost.php?p=980515&postcount=20). I have extended the bookmarklet to handle it. All other links should work as before.

Code:
javascript:(
  function(){
    /* 20170110 */
    var baseNewUrl = 'http://www.gamesquad.com/forums/index.php?threads/';
    var s=prompt('Enter URL','');
    s = s.replace(/%253A/gi,':');
    s = s.replace(/%252F/gi,'/');
    s = s.replace(/%253F/gi,'\?');
    var googleRE=/http:\/\/forums.gamesquad.com\/showthread.php\?([0-9]+)-/;
    var googleArchiveRE=/http:\/\/forums.gamesquad.com\/archive\/index.php\/t-([0-9]+)/;
    var gamesquadRE=/http:\/\/forums.gamesquad.com\/showthread.php\?t=([0-9]+)/;
    var oldNewGamesquadRE=/http:\/\/www.gamesquad.com\/xenforo\/index.php\?[^.]+\.([0-9]+)/;
    var oldPostUrlRE = /http:\/\/forums.gamesquad.com\/showpost.php\?p=([0-9]+)/;
    var newGamesquadRE=/http:\/\/www.gamesquad.com\/forums\/index.php/;
    var matchesFound=s.toLowerCase().match(googleRE);
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(googleArchiveRE);
    };
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(gamesquadRE);
    };
    if (!matchesFound ) {
      matchesFound = s.toLowerCase().match(oldNewGamesquadRE);
    }
    if ( !matchesFound ) {
      matchesFound = s.toLowerCase().match(oldPostUrlRE);
      if ( matchesFound ) {
        baseNewUrl = 'http://www.gamesquad.com/forums/index.php?posts/';
      }
    }
    if(matchesFound) {
      var newURL = baseNewUrl + matchesFound[1];
      window.open( newURL );
    }
    else {
      if ( s.toLowerCase().match(newGamesquadRE ) ) {
        window.open( s );
      }
      else {
        alert('Unable to match string as old gamesquad URL.');
      }
    };
  })()
JR
 
Last edited:

Rock SgtDan

Senior Member
Joined
Nov 29, 2012
Messages
2,579
Reaction score
125
Location
State of Confusion
First name
Dan
Country
llSlovenia
To create the bookmarklet (in Firefox, on linux), go to your bookmarks toolbar, right-click, new bookmark.... Name can be whatever you like. The Location is (expand the quoted text, copy and paste):

Save.
Using Firefox under El Capitan with a trackpad (laptop). Cannot find any way to call up a dialog box that allows me to type in a URL. There is a star shaped icon to "bookmark this page" and a "Bookmarks" dropdown. Neither give me a place to type in the URL by hand (ie a place to paste this bookmarklet).
 

benj

Senior Member
Joined
Feb 4, 2006
Messages
474
Reaction score
298
Location
France
Country
llFrance
Have you considered using document.URL instead of prompting in order to achieve a semi-automatical booktmarklet?
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
Have you considered using document.URL instead of prompting in order to achieve a semi-automatical booktmarklet?
That might have worked, but I didn't notice whether the URL was still available after the link was clicked or whether it had been changed to the generic entry page. If you want, enhance the code. It should be pretty straight forward.

JR
 

jrv

Forum Guru
Joined
May 25, 2005
Messages
21,998
Reaction score
6,206
Location
Teutoburger Wald
Country
llIceland
Recently a reader of this forum wanted to convert an old URL but was unable to install my bookmarklet in his browser (locked-down work computer). I have created a web page that will perform the same conversion: http://www.jrvdev.com/asl/tools/index.html. The page is part of a set of ASL tools I am working on. Most are just empty pages at the moment. The URL conversion utility works but is not pretty yet. Things may (or may not ;-) change in the future.

JR
 
Top