#ß K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2)
#
# ---------------------- troubleshoot_prefs.kmm   ----------------------
#  Check current setting of some prefs (useragent, cookies, referer etc.)
#  No change, only viewing.  The info text is automatically copied into the clipboard.

#  Version :   		v5  /  2017-11-12  /  by siria 
#  Menu:  		Help > Troubleshooting PREFTEST 1
#  Forum:  		http://kmeleonbrowser.org/forum/read.php?9,142878
#  K-Meleon version:   1.5 - today
# -------------------------------------------------------------------------------------------

# example UA for FF50 on Win10:
# Mozilla/5.0 (Windows NT 10.0; rv:50.0) Gecko/20100101 Firefox/50.0


troubleshoot_prefs{
macroinfo="View some settings (no change, just for checking)";
$_x="(Current GLOBAL settings. Can NOT check site exceptions!)\n\n";
&_troubleshoot_prefs_getKMver;
$_x=$_x.$_v;
$_k<"74" ? 0 : $_x=$_x."-----";
$_x=$_x."\nGENERAL.USERAGENT.OVERRIDE (fake)  ==>";
$_u=getpref(STRING,"general.useragent.override");
if ($_u) $_x=$_x."\n".getpref(STRING,"general.useragent.override");
else {
	$_u=injectJS("(function() {var x=navigator.userAgent; return x;})() ");
	if ($_u) {
		$_x=$_x."  (DEFAULT)\nnavigator.userAgent (injectJS)  ==>";
		$_x=$_x."\n".$_u;
	}else $_x=$_x."  (DEFAULT: Help>About KM)";
}
#
opentab("chrome://console2/content/blank.html");
$_u=injectJS("(function() { if(location.href.substring(0,7)!='chrome:') return '-1'; try { Components.utils.import('resource://gre/modules/Services.jsm'); Components.classes['@mozilla.org/goanna-media-plugin-service;1'].getService(Components.interfaces.mozIGoannaMediaPluginService); } catch(e) { window.close();return '0'; } window.close();return '1'; })();");
if ($_u > 0) {
	$_x=$_x."  isGoanna = YES\n";
}else if ($_u == 0) $_x=$_x."  isGoanna = NO\n";
#
$_x=$_x."\ngeneral.useragent.compatMode.firefox  =  ";
$_x=$_x.(getpref(BOOL,"general.useragent.compatMode.firefox")? "true":"false");
$_x=$_x."\ngeneral.useragent.vendor + vendorSub  =  ";
$_x=$_x.getpref(STRING,"general.useragent.vendor")." ";
$_x=$_x.getpref(STRING,"general.useragent.vendorSub");
#
$_x=$_x."\n-----";
#  Save COOKIES ?  0 (=Yes)  1 (=only from same domain)  2 (=No)   8 (=session only)
$_x=$_x."\nnetwork.cookie.cookieBehavior  =  ";
$_x=$_x.getpref(INT,"network.cookie.cookieBehavior")."   (0=all, 1=domain, 2=none, 3=special, 8=session?)";
#  Send HTTP-REFERER info? (where you arrive from, from which previous page and link)
#  0 (=No)  1 (=Yes when clicking links)  2 (=Yes from clicking links or loading images)
$_x=$_x."\nnetwork.http.sendRefererHeader  =  ";
$_x=$_x.getpref(INT,"network.http.sendRefererHeader")."   (HTTP  0=No, 1=links, 2=links+images)";
#  Send HTTPS-REFERER (encrypted pages) to other https sites?  true or false
$_x=$_x."\nnetwork.http.sendSecureXSiteReferrer  =  ";
$_x=$_x.(getpref(BOOL,"network.http.sendSecureXSiteReferrer")? "true":"false")."    (HTTPS)";
#  Block websites from exchanging pics by JS. Important for some maps, captchas etc.
$_x=$_x."\ndom.disable_image_src_set  =  ";
$_x=$_x.(getpref(BOOL,"dom.disable_image_src_set")? "true":"false")."   ('true' can block maps, captchas etc)";
#  Very basic CSS-adblock included out-of-box.
$_x=$_x."\nkmeleon.adblocking  =  ";
$_x=$_x.(getpref(BOOL,"kmeleon.adblocking")? "true":"false")."   ('true' can block too much)";
$_x=$_x."\n   (If you have other AdBlock-tools installed, check them manually)";
$_x=$_x."\n-----";
#
$_x=$_x."\nsecurity.enable_ssl3  =  ";
$_x=$_x.(getpref(BOOL,"security.enable_ssl3")? "true":"false")."    (old unsafe)";
$_t=getpref(INT,"security.tls.version.max");
if ($_t==0) {
	$_x=$_x."\nsecurity.enable_tls  =  ";
	$_x=$_x.(getpref(BOOL,"security.enable_tls")? "true":"false");
	}
$_x=$_x."\nsecurity.tls.version.min  =  ";
$_x=$_x.getpref(INT,"security.tls.version.min")."    (TLS 0=SSL3, 1=TLS 1.0, 2=TLS1.1, 3=TLS 1.2)";
$_x=$_x."\nsecurity.tls.version.max  =  ";
$_x=$_x.getpref(INT,"security.tls.version.max");
#
setclipboard($_x);
#
if (confirm($_x."\n\n        =====  Show more ? =====","V5 - Check current settings  (Text copied to clipboard):",OKCANCEL,INFO)=="OK") {  $_x="";
	opentab("about:");
	opentab("about:config");
	opentab("about:permissions");
	opentab("about:addons");
	opennew("chrome://console2/content/console2.xul");
	$_k>"75" ? popupmenu("&Privacy") : plugin("rebarmenu","&Privacy"); 
}
$_x=""; $_v=""; $_g=""; $_k=""; $_k2=""; $_k3=""; $_u=""; $_t="";
}

_troubleshoot_prefs_getKMver{
$_k="0";
$_v=readfile(getfolder(RootFolder)."\\platform.ini");
if ($_v>"") {
	$_g = iniread("Build","Milestone","", getfolder(RootFolder)."\\platform.ini");
	$_g = substr($_g,0,2); 
	$_g=="24" ? $_k="74.x" : 0;
	$_g=="31" ? $_k="75.x" : 0;
	$_g=="38" ? $_k="76.x" : 0;
	$_g=="45" ? $_k="77.x" : 0;
	$_g=="52" ? $_k="78.x" : 0;
	$_g=="59" ? $_k="79.x" : 0;
	$_g=="66" ? $_k="80.x" : 0;
	$_v="K-MELEON VERSION =  ".$_k."  (from platform.ini)\n".$_v;
	# adodupan version 1.8.24, fork of KM74, pref in kmeleon.js
	$_k2=getpref(STRING,"general.useragent.appversion");
	if ($_k2>"") $_v=sub($_k."  (from platform.ini)",$_k2." (".$_k.")  (from kmeleon.js/platform.ini)",$_v);
	$_k3 = iniread("K-Meleon","KM_Milestone","", getfolder(RootFolder)."\\platform.ini");
	if ($_k3>"") $_v=sub($_k."  (from platform.ini)",$_k3."  (from platform.ini)",$_v);
	$_v=sub("[Build]\n","",$_v);
	$_v=sub("[K-Meleon]\n","",$_v);
	$_v=sub("\nKM_Date","  /  KM_Date",$_v);
	$_v=sub("\nMilestone","  /  Gecko",$_v);
	$_v=sub("\nSourceStamp=","  /  src-",$_v);
	$_v=sub("\nSourceRepository=http://hg.mozilla.org/releases/mozilla-esr","-",$_v);
}else{
	$_v=readfile(getfolder(RootFolder)."\\defaults\\pref\\kmeleon.js");
	$_k=substr($_v,index($_v,"\"1.")+1,3);
	$_v="K-MELEON VERSION =  ".$_k."  (from kmeleon.js)"; 
}
$_v=gsub("\n\n","\n",$_v);
$_v=gsub("\n\n","\n",$_v);
$_v=gsub("\n\n","\n",$_v);
$_v=gsub("\n\n","\n",$_v);
}


_troubleshoot_prefs_BuildMenu{
setmenu(KMDocs,macro,"Troubleshooting"."  PREFTEST",troubleshoot_prefs);
}

#-------------------------------------------------
$OnInit=$OnInit."_troubleshoot_prefs_BuildMenu;";
$macroModules=$macroModules."troubleshoot_prefs;";

