General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
remember zoom
Posted by: greyowl
Date: October 16, 2014 05:12PM

I just started using K-Meleon so I am trying to figure out how it works and need some help.

I am wanting to set the zoom on a couple of websites so that it automatically opens at the specific zoom setting each time that I open that particular website. How do I get K-M to remember the site specific zoom settings.

Thank you.

Options: ReplyQuote
Re: remember zoom
Posted by: JamesD
Date: October 16, 2014 08:47PM

There may be other solutions, but one that I am using due to my eyesite is this macro. For a long time I only had it increasing the text size but recently I needed to have one site stay at size 10.

You would need to change it for text, images, or page. I have it doing text.

EaseRead.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2)
#
# ---------- EaseRead.kmm
#  Increase text size to 12 for any page loading with smaller text size
#
# Dependencies        : main.kmm
# Resources           : $TextZoom, ID_FONT_INCREASE  
# Version             : 1.1  2014_10_13
# --------------------------------------------------------------------------------

_EaseRead_AutoRun {
$_EaseRead_TextNO = $TextZoom ;
while ($_EaseRead_TextNO < 12 ) { 
	id(ID_FONT_INCREASE) ; 
	$_EaseRead_TextNO = $TextZoom ;
	}

if ($URLBAR == "http://www.gmx.com/"winking smiley {	
	while ($_EaseRead_TextNO > 10 ) { 
		id(ID_FONT_DECREASE) ; 
		$_EaseRead_TextNO = $TextZoom ;
		}
	}	
}

## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$OnLoad=$OnLoad."_EaseRead_AutoRun;"; 
$macroModules=$macroModules."EaseRead;";


Options: ReplyQuote
Re: remember zoom
Posted by: siria
Date: October 17, 2014 01:24AM

@James: Nice - I like smiling smiley
And learned something again: Never knew about $TextZoom before!

But the code is a bit too javascriptish for my taste, couldn't resist playing with it ;-)

Quote

_EaseRead_AutoRun {
$_zoom="12";
#
if (hostname($URL) == "kmeleon.sourceforge.net") $_zoom="16";
if (hostname($URL) == "www.example2.com") $_zoom="14";
if (index($URL,"kmeleonbrowser.org/forum/")>-1) $_zoom="10";
#
while ($TextZoom < $_zoom ) id(ID_FONT_INCREASE) ;
while ($TextZoom > $_zoom ) id(ID_FONT_DECREASE);
}

$OnLoad=$OnLoad."_EaseRead_AutoRun;";

Find it quite an interesting zoom function. The advantage compared to setting a simple min-font-size in the pref sheets is that not ALL text gets exactly the same size, but the steps are kept, headlines still remain bigger etc.
Guess in theory it couldn't work with page zoom, since page zoom does not change $TextZoom, but haven't tested.

Just one little issue: The loop doesn't seem to do anything if Zoom value is set smaller 10?
And perhaps a user-switch during session wouldn't be bad, perhaps incl. a live change of default zoom, but I get carried away as always ;-) Hmm, and a way to disable default zoom...



@greyowl:
Am no expert in zooming, just a user who likes a bit playing with macros, so all I can tell is there's is no native KM way to do this at the moment.
But I think aside from this tiny macro there are more out there already, also for site-specific "page zooming", and probably with a menu. Look around in kmext.sf.net and here in the forum under "extensions".

If you want to test a simple text macro like the above one, run Notepad and copy the lines into a text file, and save it as EaseRead.kmm or other name into the macros folder, just without the txt-ending. Restart of browser required.



Edited 1 time(s). Last edit at 10/17/2014 01:35AM by siria.

Options: ReplyQuote
Re: remember zoom
Posted by: Dorian
Date: October 17, 2014 04:59PM

For some reason $TextZoom is a string, so you have to use a number for the comparaison:
_EaseRead_AutoRun {
$_zoom=12;
#
if (hostname($URL) == "kmeleon.sourceforge.net") $_zoom=16;
if (hostname($URL) == "www.example2.com") $_zoom=14;
if (index($URL,"kmeleonbrowser.org/forum/")>-1) $_zoom=10;
#
while ($_zoom > $TextZoom ) id(ID_FONT_INCREASE) ;
while ($_zoom < $TextZoom ) id(ID_FONT_DECREASE);
}

However, $TextZoom is supposed to be writable so the following should work:
$TextZoom = $_zoom;

And using the prefs you could do theorically something like that:

_EaseRead_AutoRun {
$default = getpref(INT, "zoom.defaultPercent", 100) / 10;
$TextZoom = getpref(INT, "kmeleon.macros.easeread.".hostname($URL).".textzoom", $default);
}


Options: ReplyQuote
Re: remember zoom / default and site-specific zoom
Posted by: siria
Date: October 17, 2014 06:31PM

What a fantastic little default variable! smiling smiley smiling smiley
Thanks for explaining, so even the two ID-lines can now be dropped.
And sounds really easy to just store the domains with site-specific zoom in the prefs.
This could really become a handy default function, next to default page zoom smiling smiley

But now am confused about the GETpref lines:
So far I know this only with 2 arguments - what does the 3rd do?

Options: ReplyQuote
Re: remember zoom / default and site-specific zoom
Posted by: Dorian
Date: October 17, 2014 10:23PM

Nothing. I just though you could pass the default value in case the pref is missing, but you have to handle it yourself.

Options: ReplyQuote
Re: remember zoom / default and site-specific zoom
Posted by: JamesD
Date: October 17, 2014 11:55PM

After searching three backup drives, I found this old macro. I have not loaded or checked it in at least a couple of years.

AutoZoom.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2)
#  
# ---------- AutoZoom.kmm
# ---------- K-Meleon Macro Remember zoom for certain URLs ---------------
#
# Dependencies        : main.kmm zoom.kmm
# Resources           : - 
# Preferences         : "k-meleon_autozoom.[integer].sites"  STRING
#					  : "k-meleon_autozoom.integers"   STRING
# Version             :  0.2   2011-09-29
# --------------------------------------------------------------------------------

_AutoZoom_ReZoom {
##  first check the integers - then for each integer check its site list for a hit
$_AutoZoom_Integers = getpref( STRING, "k-meleon_autozoom.integers") ;
$_AutoZoom_Len = length($_AutoZoom_Integers);
$_AutoZoom_ICount = 0;
while ($_AutoZoom_ICount < $_AutoZoom_Len) {
	$_AutoZoom_IIdx = index($_AutoZoom_Integers, " ");
	$_AutoZoom_check = substr($_AutoZoom_Integers, 0, $_AutoZoom_IIdx) ;
	#alert($_AutoZoom_check, "$_AutoZoom_check  DEBUG", INFO);
	## $_AutoZoom_check contains a zoom integer as text
	macros(_AutoZoom_Site_Search) ;
	if ($_AutoZoom_ICount < $_AutoZoom_Len) {
		$_AutoZoom_Integers = substr($_AutoZoom_Integers, $_AutoZoom_IIdx +1);
		$_AutoZoom_ICount = $_AutoZoom_ICount + ($_AutoZoom_IIdx +1);
	}
}
}

_AutoZoom_Site_Search {
## for a specific integer, $_AutoZoom_check, test the list of sites
$_AutoZoom_Sites = getpref( STRING, "k-meleon_autozoom.".$_AutoZoom_check.".sites");
$_AutoZoom_LenS = length($_AutoZoom_Sites);
$_AutoZoom_SCount = 0;
while ($_AutoZoom_SCount < $_AutoZoom_LenS ) {
	$_AutoZoom_SIdx = index($_AutoZoom_Sites, " ");
	$_AutoZoom_Scheck = substr($_AutoZoom_Sites, 0, $_AutoZoom_SIdx) ;
	#alert($_AutoZoom_Scheck, "$_AutoZoom_Scheck  DEBUG", INFO);
	if ($URL == $_AutoZoom_Scheck) {  ## found a match in the list
		$TextZoom = (0 + $_AutoZoom_check) ;
		$_AutoZoom_SCount = $_AutoZoom_LenS ; # look no more sites
		$_AutoZoom_ICount = $_AutoZoom_Len ;  # look no more integers 
		} else {
		$_AutoZoom_Sites = substr($_AutoZoom_Sites, $_AutoZoom_SIdx +1);
		$_AutoZoom_SCount = $_AutoZoom_SCount + ( $_AutoZoom_SIdx + 1) ;
	}
}
}

_AutoZoom_SetURL {
macroinfo = "Add current URL to AutoZoom at zoom ".$TextZoom ; 
if (getpref(STRING, "k-meleon_autozoom.".$TextZoom.".sites") == "" ) {
	setpref(STRING, "k-meleon_autozoom.".$TextZoom.".sites", $URL . " ") ;
	macros(_AutoZoom_Integer_Set);
	} else {
	$_AutoZoom_current = getpref(STRING, "k-meleon_autozoom.".$TextZoom.".sites") ;
	$_AutoZoom_extended = $_AutoZoom_current . $URL ;
	setpref(STRING, "k-meleon_autozoom.".$TextZoom.".sites", $_AutoZoom_extended . " ") ;
	macros(_AutoZoom_Integer_Set);
}
}

_AutoZoom_Integer_Set {
$_AutoZoom_Integers = getpref( STRING, "k-meleon_autozoom.integers") ;
$_AutoZoom_ICheck = index($_AutoZoom_Integers, $TextZoom );
if ( $_AutoZoom_ICheck == -1 ) {
	setpref(STRING, "k-meleon_autozoom.integers", $_AutoZoom_Integers . $TextZoom  . " ") ;
	}
	# if other than -1 then integer already exists in the string
}

_AutoZoom_DropURL {
macroinfo = "Remove current URL from AutoZoom. "; 
$_AutoZoom_Integers = getpref( STRING, "k-meleon_autozoom.integers") ;
$_AutoZoom_AllIntegers = $_AutoZoom_Integers ; # preserve a copy
$_AutoZoom_Len = length($_AutoZoom_Integers);
$_AutoZoom_ICount = 0;
while ($_AutoZoom_ICount < $_AutoZoom_Len) {
	$_AutoZoom_IIdx = index($_AutoZoom_Integers, " ");
	$_AutoZoom_check = substr($_AutoZoom_Integers, 0, $_AutoZoom_IIdx) ;
	macros(_AutoZoom_Site_UnSet) ;
	if ($_AutoZoom_ICount < $_AutoZoom_Len) {
		$_AutoZoom_Integers = substr($_AutoZoom_Integers, $_AutoZoom_IIdx +1);
		$_AutoZoom_ICount = $_AutoZoom_ICount + ($_AutoZoom_IIdx +1);
	}
}
}

_AutoZoom_Site_UnSet {
## for a specific integer, $_AutoZoom_check, test the list of sites
$_AutoZoom_Sites = getpref( STRING, "k-meleon_autozoom.".$_AutoZoom_check.".sites");
$_AutoZoom_AllSites = $_AutoZoom_Sites ; # preserve a copy
$_AutoZoom_LenS = length($_AutoZoom_Sites);
$_AutoZoom_SCount = 0;
while ($_AutoZoom_SCount < $_AutoZoom_LenS ) {
	$_AutoZoom_SIdx = index($_AutoZoom_Sites, " ");
	$_AutoZoom_Scheck = substr($_AutoZoom_Sites, 0, $_AutoZoom_SIdx) ;
	#alert($_AutoZoom_Scheck, "$_AutoZoom_Scheck  DEBUG", INFO);
	if ($URL == $_AutoZoom_Scheck) {  ## found a match in the list
		$_AutoZoom_Replace =  gsub( $URL." ", "", $_AutoZoom_AllSites );
		if (length($_AutoZoom_Replace) > 0 ) { 
			setpref(STRING, "k-meleon_autozoom.".$_AutoZoom_check.".sites", $_AutoZoom_Replace);
			} else {
			delpref("k-meleon_autozoom.".$_AutoZoom_check.".sites");
			$_AutoZoom_IReplace =  gsub( $_AutoZoom_check." ", "", $_AutoZoom_AllIntegers );
			if (length($_AutoZoom_IReplace) > 0 ) { 
				getpref( STRING, "k-meleon_autozoom.integers", $_AutoZoom_IReplace ) ;
				} else {
				delpref("k-meleon_autozoom.integers");
				}
		}
		$_AutoZoom_SCount = $_AutoZoom_LenS ; # look no more sites
		$_AutoZoom_ICount = $_AutoZoom_Len ;  # look no more integers 
		} else {
		$_AutoZoom_Sites = substr($_AutoZoom_Sites, $_AutoZoom_SIdx +1);
		$_AutoZoom_SCount = $_AutoZoom_SCount + ( $_AutoZoom_SIdx + 1) ;
	}
}
}

_AutoZoom_BuildMenu{
setmenu("PageDisplay",popup,"Auto Zoom",-1);
setmenu("Auto Zoom",macro,"Include",_AutoZoom_SetURL,0);
setmenu("Auto Zoom",macro,"Delete",_AutoZoom_DropURL,1);

}

$OnInit=$OnInit."_AutoZoom_BuildMenu;";
$OnLoad=$OnLoad."_AutoZoom_ReZoom;";
$macroModules=$macroModules."AutoZoom;";


Options: ReplyQuote
Re: remember zoom / default and site-specific zoom
Posted by: siria
Date: October 19, 2014 11:26AM

Couldn't stop myself from creating a new macro, blowing up the first beautiful microscopic example just to add some menu settings.
But it does now use that great solution with adding the hostname in the pref names, thanx smiling smiley

But am running into a major prob again:
As soon as a user zooms the "page", which is the default action for mousewheel-zoom, the size looks completely different as when using text zoom only :-(

Is there any chance to figure out that $PageZoom size for further use in a macro??
It does seem to exist somewhere, because the status bar shows after a page zoom (by button) exactly the same info as after a text zoom, just "full":
"Full Zoom: 12"
Tried some guessing with trial-and-error and workarounds, but no chance, nothing works sad smiley

Here is a first beta version if anyone would like to test:
http://kmeleonbrowser.org/forum/file.php?10,file=899,filename=SiteZoom_beta1.kmm.7z

Options: ReplyQuote
Re: remember zoom / default and site-specific zoom
Posted by: JamesD
Date: October 19, 2014 01:28PM

Quote
siria
But am running into a major prob again:
As soon as a user zooms the "page", which is the default action for mousewheel-zoom, the size looks completely different as when using text zoom only :-(

Is there any chance to figure out that $PageZoom size for further use in a macro??
It does seem to exist somewhere, because the status bar shows after a page zoom (by button) exactly the same info as after a text zoom, just "full":
"Full Zoom: 12"
Tried some guessing with trial-and-error and workarounds, but no chance, nothing works sad smiley

I was just about to ask Dorian for a small improvement. In the macro language we have $TextZoom which hold an integer value for the current text zoom. I am going to propose that he create a similar variable and call it $FullZoom. I think that it should be as simple as copying the code which creates $TextZoom, point it at the same place the status bar gets the value for full zoom, and name the output $FullZoom. I know some other internal variables will need name changes also, but maybe there are not too many of them.

Do you think this post is enough to bring the need to Dorian's attention or do you think I need to post in the Improvements section also?

Options: ReplyQuote


K-Meleon forum is powered by Phorum.