Man!! Can't believe how easy that is, after struggling for such a long time and searching around and messing macros and workarounds without success. And now it turns out there's just 1 simple line needed! *dropdead*
Continued from here
http://kmeleonbrowser.org/forum/read.php?1,104538,page=2
___________________________________________
K-Meleon has a default setting for animated gifs: Play normal, or 1x, or not (=static image). But after a page was already loaded, already animated gifs can't be stopped anymore (KM1.6b2 + older). This macro allows to STOP all already running animated gifs after a page was already loaded.
___________________________________________
It works beautifully on the "Block Animation" button now, instantly and without any scrolling
Actually, it isn't specifically to stop animation, but to
stop the whole page!
Whatever else that stops... scripts obviously not... perhaps I should rename it?
Hmm, funny... Now when hitting the "Block Animation" (=alternative STOP) Button, a currently loading page stops in the middle, that's okay, but the already loaded gifs are still shown moving. Toggling the button ON/OFF again now stops the animations too! Does it have to be fired 2x??
PS: For testing or whatever, you can also just use this as a
bookmarklet:
javascript:window.stop()
PS2: The keyboard shortcut (Shift+ESC) works sometimes and other times not, no idea why?
___________________________________________
"Installation": Copy the blue text into a new text file, and save it as "KillAnim.kmm" into one of your macros folders. Must NOT have a .txt ending. Restart browser.
___________________________________________
# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2)
#
# ----------------------------- KillAnim.kmm --------------------------
# K-Meleon has a default setting for animated gifs: Play normal, or 1x, or not (=static image)
# But after a page was already loaded, already animated gifs can't be stopped anymore (KM1.6b2 + older)
# This macro allows to STOP already running animated gifs (1 or all) after a page was already loaded.
# Note: UN-blocking will NOT re-animate them, once killed they'll stay dead until the page is reloaded again ;-)
#
# VERSION: v4.01 / 2011-05-29 (by siria)
#
# MENUS:
# Right-click any image > Kill Animation (1 or all)
# Or click Tools > Privacy > "Kill Animation" or "Block Animation", or the Animation Button in Privacy Toolbar
# Forum: kmeleon.sf.net/forum/read.php?9,116553
#----------------------------------------------------------------------------
#
# TIP: If you use the lovely Privacy Toolbar, add the "Kill" menu (Flash, Java, Animations)
# as right-click context menu on a button, e.g. on the "Kill Flash" button, or the Animation button:
# Edit > Configuration > Toolbars
# Example for Flash: Replace "macros(JS_killFlash)" with "macros(JS_killFlash)|_Privacy_Kill"
# Or example to add whole Privacy Menu on Animation button right-clicks:
# "macros(pref_ToggleAnimation)|&Privacy"
JS_killAnimation{
macroinfo=_("Stop all animated gif images in this page");
# If extension "Policy Manager" is used, allow this stop command
$pref_PolJS="capability.policy.default.javascript.enabled";
$_bak=getpref(STRING,$pref_PolJS);
$_bak=="noAccess" ? setpref(STRING,$pref_PolJS,"allAccess"):0;
injectJS("window.stop()");
$_bak=="noAccess" ? setpref(STRING,$pref_PolJS,"noAccess"):0;
}
pref_ToggleAnimation{
macroinfo=_("Toggle image animation");
menuchecked=(getpref(STRING,$pref_Animation)=="none");
togglepref(STRING,$pref_Animation,"normal","none"); &_pref_SyncButtons;
statusbar(sub("%s",getpref(STRING,$pref_Animation)=="none"?$off:$on,_("Image animation %s")));
##### mod. by siria
getpref(STRING,$pref_Animation)=="none" ? &JS_killAnimation : 0;
}
# Next one is still the long-winded old workaround from v2, to stop just 1 image:
KillAnim_1image{
macroinfo="Kill 1 image animation (workaround, sorry, some sites don't work. Opens single image then navigates back and reloads from cache)";
$_killanim1bak=getpref(STRING,"image.animation_mode");
$_killanim2bak=getpref(INT,"browser.cache.check_doc_frequency");
setpref(STRING,"image.animation_mode","none");
setpref(INT,"browser.cache.check_doc_frequency",2);
open($ImageURL);
$OnLoadOnce=$OnLoadOnce."_KillAnim_1imageB;";
}
_KillAnim_1imageB{
id(ID_NAV_BACK);
setpref(STRING,"image.animation_mode",$_killanim1bak);
setpref(INT,"browser.cache.check_doc_frequency",$_killanim2bak);
&_pref_SyncButtons;
}
_KillAnim_BuildMenu{
# Keyboard shortcut: Shift+ESC (not sure if it works?)
setaccel("SHIFT VK_ESCAPE","macros(JS_killAnimation)");
#
setmenu(_Privacy_Kill,macro,"Kill Animation",JS_killAnimation,-1);
setmenu("ImageView",macro,"Kill Animation (Stop page)",JS_killAnimation,-1);
setmenu("ImageView",macro,"Kill Animation (Stop 1)",KillAnim_1image,-1);
# Optional: If you also want it on the context menu (right-click) of the Reload button:
# setmenu("Reloa&ding",macro,"Kill Animation (Stop)",JS_killAnimation,-1);
}
#--------------------- BROWSER START ----------------------
$OnInit=$OnInit."_KillAnim_BuildMenu;";
$macroModules=$macroModules."KillAnim;";
Edited 15 time(s). Last edit at 05/30/2011 07:05PM by siria.