Extensions :  K-Meleon Web Browser Forum
All about K-Meleon extensions. 
EXIT translation or redirects! (escape google etc.)
Posted by: siria
Date: January 20, 2010 11:35PM

EDIT: 2010-06-03 Update Version 1.6:

v1.4: Added menu entries to replace those annoying %-codes in URLs!
Find it by clicking on the Go-Button (for URL bar) or right-clicking on links.

v1.5: Added menu entry on Go-Button: "Paste And Go in New", replacing %-code in URL from clipboard

v1.6: More replacing syntax: for extracting URL from google cache errors, and crop image-URLs with "&" and other trailing stuff at end

-----------------------------------------------

As great as google translations are, but it's been a long time that it's getting on my nerves that once you're there, you only can escape again if editing the URL bar manually. Or perhaps it's just because I don't use javascript or there's some trick or I'm just blind!! But anyway, I'm fed up and here's now a macro that adds a few menu entries to escape:
Click on Tools > Translations to find one, or right-click on a page, or frame, or link. If you want fewer entries, simply comment out the setmenu lines at the bottom, it's quite easy!

This should work to escape Google Translations, babelfish, but also many other redirected URLs (not just translations).

example link for google
example link for babelfish
example link for %-codes

As usual, open notepad or another editor, and copy into it the blue lines below, then save as "ExitTranslation.kmm" in your macros folder (make sure there's no .txt at the end). Restart browser.

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)

# -------------------------- ExitTranslation.kmm ---------------- v1.6 (2010-06-03 , by Siria)
# Dependencies: main.kmm
# Resources: -
# Preferences: -
# Menu entries "EXIT translation or redirects": Tools > Translation, or RIGHT-CLICK on a PAGE, or FRAME, or LINK
# Menu entries "REPLACE %-CODE": on Go-Button (for URL) or RIGHT-CLICK on LINK
# Web + Forum: kmeleon.sf.net/wiki/KmmExitTranslation + kmeleon.sf.net/forum/read.php?9,100742
#--------------------
# VERSION 1.4: New menu entries: REPLACE %-CODES on Go-Button (for URL) or RIGHT-CLICK on LINK
# VERSION 1.5: New menu entry: Go-Button with "Paste And Go in New", replacing %-code in URL from clipboard
# VERSION 1.6: Added syntax for Google Cache error, and crop URLs after image endings (.jpg& etc)
#--------------------

#
# A macro to escape from Google Translations, babelfish, but also many other redirected URLs (not just translations).
# Instead of cleaning redirects, there can also just those pesky %-codes converted (%20=" " etc.)
# NOTE: If a separate frame is on top of the page, the URL usually never changes when surfing around.
# Then you may have to right-click in the frame below and click "Frame > EXIT Translation".
# It may even help already to just click "Frame > Show only this frame"

#================= CUSTOMIZING ====================
#
# BUTTON-command for toolbars.cfg : "macros(ExitTranslation_Page)|&Translation"
# BUTTON-tooltip e.g.: "EXIT from translation or other redirected URL (right-click for Translation menu)"
# MENUS: To change menu entries (position and text): Modify the setmenu-lines at the bottom
# OPEN IN NEW, OR in current tab, OR in background: Set "#" in front of 2 of the 3 "open"-lines below

#==================== CODE ========================

ExitTranslation_Page{
macroinfo="EXIT from forced translation or other redirect";
$_url=$URL ;
&_ExitTranslation_extracturl;
open($OpenURL);
# &OpenURL_InNew;
# &OpenURL_InBg;
}

ExitTranslation_Frame{
macroinfo="EXIT from forced translation or other redirect";
$_url=$FrameURL ;
&_ExitTranslation_extracturl;
open($OpenURL);
# &OpenURL_InNew;
# &OpenURL_InBg;
}

ExitTranslation_Link{
macroinfo="Open In New - EXIT from forced translation or other redirect";
$_url=$LinkURL ;
&_ExitTranslation_extracturl;
# open($OpenURL);
&OpenURL_InNew;
# &OpenURL_InBg;
}

ExitTranslation_DecodePage{
macroinfo="URL: Replace %-codes";
$_url=$URL ;
&_ExitTranslation_decode;
open($OpenURL);
}

ExitTranslation_DecodeLink{
macroinfo="Open link - Replace %-codes";
$_url=$LinkURL ;
&_ExitTranslation_decode;
# open($OpenURL);
&OpenURL_InNew;
# &OpenURL_InBg;
}

ExitTranslation_GoPasteNew{
macroinfo=_("Get Clipboard, replace %-codes and open as URL in New Tab/Window");
$_url=getclipboard();
&_ExitTranslation_decode;
&OpenURL_InNew;
}

_ExitTranslation_extracturl{
# replace %-codes:
&_ExitTranslation_decode;
# cut at BEGINNING:
$_url=substr($_url,4);
index($_url,"http")>-1 ? $_url=substr($_url,index($_url,"http")) : 0;
index($_url,"&url=")>-1 ? $_url=substr($_url,index($_url,"&url=")+5) : 0;
# When clicking on "cache" in a google search, sometimes there's only an error message. Exit:
if (index($_url,"googleusercontent.com/search?q=cache:")>-1) {
$_url=substr($_url,index($_url,"googleusercontent.com/search?q=cache:")+37);
$_url=substr($_url,index($_url,":")+1);
}
# cut at END: (&rurl= &hl= suffixes from google translate)
index($_url,"+")>-1 ? $_url=substr($_url,0,index($_url,"+")) : 0;
index($_url,".htm&")>-1 ? $_url=substr($_url,0,index($_url,".htm&")+4) : 0;
index($_url,".html&")>-1 ? $_url=substr($_url,0,index($_url,".html&")+5) : 0;
index($_url,".jpg&")>-1 ? $_url=substr($_url,0,index($_url,".jpg&")+4) : 0;
index($_url,".gif&")>-1 ? $_url=substr($_url,0,index($_url,".gif&")+4) : 0;
index($_url,".png&")>-1 ? $_url=substr($_url,0,index($_url,".png&")+4) : 0;
index($_url,"&rurl=")>-1 ? $_url=substr($_url,0,index($_url,"&rurl=")) : 0;
index($_url,"&hl=")>-1 ? $_url=substr($_url,0,index($_url,"&hl=")) : 0;
$OpenURL=$_url;
}

_ExitTranslation_decode{
# replace %-codes: can't take urldecode($OpenURL), it cuts beginning if url has "/ */http"
$_url=gsub("%3a",":",$_url); $_url=gsub("%3A",":",$_url);
$_url=gsub("%2f","/",$_url); $_url=gsub("%2F","/",$_url);
$_url=gsub("%20"," ",$_url);
$_url=gsub("%26","&",$_url);
$_url=gsub("%3f","?",$_url); $_url=gsub("%3F","?",$_url);
$_url=gsub("%3d","=",$_url); $_url=gsub("%3D","=",$_url);
$OpenURL=$_url;
}

# Modify your menu entries below. The entry text right after "macro" can freely be changed.
# The numbers in the end are the line position in the menu (0=on top, "-1" or nothing = at end)
# Set a # at the beginning to hide a menu entry.

_ExitTranslation_BuildMenu{
setmenu("&Translation",macro,"EXIT translation or redirect",ExitTranslation_Page,0);
setmenu("DocumentSave",macro,"EXIT translation or redirect",ExitTranslation_Page,-1);
setmenu("FrameSave",macro,"EXIT translation or redirect",ExitTranslation_Frame,-1);
setmenu("LinkOpen",macro,"Open In New - EXIT translation or redirect",ExitTranslation_Link,-1);
setmenu("LinkOpen",macro,"Open In New - Replace %-codes",ExitTranslation_DecodeLink,-1);
setmenu(_Go_Clipboard,macro,"URL: Replace %-codes",ExitTranslation_DecodePage,-1);
setmenu(_Go_Clipboard,macro,"Paste And Go in New Page",ExitTranslation_GoPasteNew,"Paste And &Search");
# setmenu("LinkSave",macro,"EXIT Translation - Open Link In New",ExitTranslation_Link,-1);
}

#------------------------ on browser start --------------------
$OnInit=$OnInit."_ExitTranslation_BuildMenu;";
$macroModules=$macroModules."ExitTranslation;";




Edited 12 time(s). Last edit at 06/04/2010 12:37AM by siria.

Options: ReplyQuote
Re: EXIT translation or redirects! (escape google etc.)
Posted by: siria
Date: January 29, 2010 08:36PM

Update to version 1.4, more options added:
New menu entries just to convert those %xy-codes in URLs to normal characters.
(That %-stuff tends to produce "Page not found" errors)

Was trying out "urldecode", but with waybackmachine that command cuts off the whole first part of an URL, so sticked again with the manual one-by-one-replacing method, for now...

Options: ReplyQuote
Re: EXIT translation or redirects! (escape google etc.)
Posted by: siria
Date: June 04, 2010 12:08AM

Update to version 1.6, see above.

Options: ReplyQuote
Re: EXIT translation or redirects! (escape google etc.)
Posted by: Jose
Date: April 14, 2011 09:21PM

How I can Use it in Blogger?

Options: ReplyQuote


K-Meleon forum is powered by Phorum.