I'm having a problem with a bookmarklet. You see, when I excecute this code normally and without compression it works, but when I compress it and put it in a bookmark it throws an unexpected ; error.
Uncompressed:
javascript:(
listOfServers = [ "Vodlocker" , "Played" , "MovShare" , "NowVideo" ];
for( var i = 0 ; i < listOfServers.length ; i ++ ){
var currentServer = listOfServers[ i ].toLowerCase();
var link = document.querySelector( 'a[title=' + currentServer + ']' );
if( link != null ){
link.click(); break
}
}
)();
Compressed:
listOfServers=["Vodlocker","Played","MovShare","NowVideo"];for(var i=0;i<listOfServers.length;i++){var currentServer=listOfServers[i].toLowerCase();var link=document.querySelector('a[title='+currentServer+']');if(link!=null){link.click();break}}
Compressing website (really don't think is needed but..)
So, what am I doing wrong? I'm sorry if this has been answerd, I checked a few questions and they didn't have this specific problem.
Thanks in advance! :)
-- Edit --
Error (if it wasn't clear)
Uncaught SyntaxError: Unexpected token ;
When I paste your compressed version into the Firefox console, I don't get any error.
Your compressed version is not a bookmarklet, so to test it as a bookmarklet I tried using the pattern you showed above, which is javascript:(...)();
. When I do that, I get an error, but one that is different than you report.
Thing is, the usual pattern is javascript:(function(){...})();
. When I used that pattern as a bookmarklet to hold your compressed code, I got no error.