K-Meleon

KMeleonWiki > Resources > MacroLibrary > KmmDisableCSS

Submitted by: desga2



Notes:

This code it's a good example for how to use injecJS() macro function.

This add a privacy option to clear all CSS styles in current page. With this code a new option can be checked in menu:
Tools -> Privacy -> Disable CSS
Also included an accelerator to toggle his state, key: F10


Open your User Macro Folder (Edit > Configuration > User-Defined Macros) or your Macro Folder (Edit > Configuration > Macros) and create the following text file(s):

DisableCSS.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- DisableCSS.kmm for K-Meleon 1.5.x ----------------------------------------------------
#
# Dependencies        : main.kmm, JavaScript
# Resources           : -
# Preferences         : kmeleon.disablecss
# Version             : 1.0
# -------------------------------------------------------------------------------------------------
#

DisableCSS{
macroinfo=_("Toggle CSS Styles");
menuchecked=getpref(BOOL,"kmeleon.disablecss");
menugrayed=!getpref(BOOL,$pref_JavaScript);
togglepref(BOOL,"kmeleon.disablecss");
&Toggle_CSS;
statusbar(sub("%s",getpref(BOOL,"kmeleon.disablecss")?$off:$on,_("CSS Styles %s")));
}

Toggle_CSS{
getpref(BOOL,"kmeleon.disablecss")?$JS_doit="(function(){var i,x;for(i=0;x=document.styleSheets[i];++i)x.disabled=true;})();":$JS_doit="(function(){var i,x;for(i=0;x=document.styleSheets[i];++i)x.disabled=false;})();";
&JS_hndlDoc;
}

_DisableCSS_BuildMenu{
# Tools -> Privacy:
setmenu("_Privacy_Settings",macro,_("Disable CSS"),"DisableCSS","Block Image Ani&mation");
# View and Page properties context menu:
#setmenu("Page &Properties",macro,_("Disable CSS"),"DisableCSS",-1);
setaccel("VK_F10","macros(DisableCSS)");
}

# -------------------------------------------------------------------------------------------------
$OnInit=$OnInit."_DisableCSS_BuildMenu;";
$macroModules=$macroModules."DisableCSS;";


Comments & Questions

K-Meleon

(c) 2000-2010 kmeleonbrowser.org. All rights reserved.
design by splif.