K-Meleon
KMeleonWiki > Resources > MacroLibrary > KmmExitTranslation
Submitted by: Siria
A macro to escape from Google Translations, babelfish, but also many other redirected URLs (not just translations).
NOTE: If a separate frame is on top of the page, the address in the URL bar usually never changes when surfing around. Then you may have to right-click in the frame below and first choose "Frame", then "EXIT Translation".
Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
# -------------------------- ExitTranslation.kmm ---------------- v1.3 (2010-01-23 , by Siria)
# Dependencies: main.kmm
# Resources: -
# Preferences: -
# Menu entry: Tools > Translation > "EXIT translation", or RIGHT-CLICK on a PAGE, or FRAME, or LINK
# Web + Forum: kmeleon.sf.net/wiki/KmmExitTranslation + kmeleon.sf.net/forum/read.php?9,100742
#--------------------
#
# A macro to escape from Google Translations, babelfish, but also many other redirected URLs (not just translations).
# 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 first choose "Frame", then "EXIT Translation".
#================= 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{
$OpenURL=$URL ;
&_ExitTranslation_extracturl;
open($OpenURL);
# &OpenURL_InNew;
# &OpenURL_InBg;
}
ExitTranslation_Frame{
$OpenURL=$FrameURL ;
&_ExitTranslation_extracturl;
open($OpenURL);
# &OpenURL_InNew;
# &OpenURL_InBg;
}
ExitTranslation_Link{
$OpenURL=$LinkURL ;
&_ExitTranslation_extracturl;
# open($OpenURL);
&OpenURL_InNew;
# &OpenURL_InBg;
}
_ExitTranslation_extracturl{
# cut at BEGINNING:
$OpenURL=substr($OpenURL,4);
index($OpenURL,"&url=")>-1 ? $OpenURL=substr($OpenURL,index($OpenURL,"&url=")+5) : 0;
$OpenURL=substr($OpenURL,index($OpenURL,"=http")+1);
$OpenURL=substr($OpenURL,index($OpenURL,":http")+1);
# cut at ENDING: (&rurl=suffix from google translate)
index($OpenURL,".htm&")>-1 ? $OpenURL=substr($OpenURL,0,index($OpenURL,".htm&")+4) : 0;
index($OpenURL,".html&")>-1 ? $OpenURL=substr($OpenURL,0,index($OpenURL,".html&")+5) : 0;
index($OpenURL,"&rurl=")>-1 ? $OpenURL=substr($OpenURL,0,index($OpenURL,"&rurl=")) : 0;
index($OpenURL,"&hl=")>-1 ? $OpenURL=substr($OpenURL,0,index($OpenURL,"&hl=")) : 0;
$OpenURL=gsub("%3a",":",$OpenURL); $OpenURL=gsub("%3A",":",$OpenURL);
$OpenURL=gsub("%2f","/",$OpenURL); $OpenURL=gsub("%2F","/",$OpenURL);
$OpenURL=gsub("%20"," ",$OpenURL);
$OpenURL=gsub("%26","&",$OpenURL);
$OpenURL=gsub("%3f","?",$OpenURL); $OpenURL=gsub("%3F","?",$OpenURL);
$OpenURL=gsub("%3d","=",$OpenURL); $OpenURL=gsub("%3D","=",$OpenURL);
}
# 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",ExitTranslation_Page,0);
setmenu("DocumentSave",macro,"EXIT translation",ExitTranslation_Page,-1);
setmenu("FrameSave",macro,"EXIT translation",ExitTranslation_Frame,-1);
setmenu("LinkOpen",macro,"Open In New Tab/Window - EXIT translation",ExitTranslation_Link,-1);
# setmenu("LinkSave",macro,"EXIT Translation - Open Link In New",ExitTranslation_Link,-1);
}
#------------------------ on browser start --------------------
$OnInit=$OnInit."_ExitTranslation_BuildMenu;";
$macroModules=$macroModules."ExitTranslation;";