General :  K-Meleon Web Browser Forum
General discussion about K-Meleon 
macro help(variables)
Posted by: disrupted
Date: January 08, 2009 11:10PM

messed up.. is it doable? how to activate? or rather always keep active

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- user agent autoswitcher tester fester
#
# Dependencies : -
# Resources : -
# Preferences : -
# --------------------------------------------------------------------------------



autoswitcher{
if $URLBAR = "http://login.live.com";
then
setpref( STRING, "general.useragent.override, Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18 );
}


# ------------------------------------------------------------------------------------------------------------------
$OnInit=$OnInit."autoswitcher_BuildMenu;";
$macroModules=$macroModules."autoswitcher;"


Options: ReplyQuote
Re: macro help(variables)
Posted by: JamesD
Date: January 09, 2009 12:08AM

The problem is when is the macro going to look at the URLBAR? We have an event called onload but that is after the site has loaded. I cannot think of a way to tell the macro to check the URLBAR except by user intervention.

Maybe OnOpenTab if the URLBAR is completed before the event. I would have to run some tests.



Edited 1 time(s). Last edit at 01/09/2009 12:12AM by JamesD.

Options: ReplyQuote
Re: macro help(variables)
Posted by: JamesD
Date: January 09, 2009 01:16AM

Well there is a way. An early proof of concept macro that I wrote for this thread http://kmeleonbrowser.org/forum/read.php?2,87243 can be made to work for user agent change for specific sites. I put some extra code in the load macro. The alert to force a wait is required. Otherwise the load happens before or while the update of the pref is still happening. You could fix the new Groups2 code ( same thread ) load macros.

GroupsUnit.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#  
# ---------- GroupsUnit.kmm
# ---------- K-Meleon Macro Language  Save/Open group of URLs in tabs ----
#
# Dependencies        : - main.kmm KM version 1.5 tabs
# Resources           : - 
# Preferences         : - k-meleon_GroupsUnit.<name>.<#>
#                     : - k-meleon_GroupsUnit.<name>.Cnt
# Version             : - 0.2   2008-12-29
# --------------------------------------------------------------------------------

_GroupsUnit_RunCode_Save{
macroinfo="Save the current tab's URLS";
$_GroupsUnit_Name = prompt("Assign a name for this group.", "GroupUnit Name (save)");
$_GroupsUnit_Number_of_Tabs = $TabNumber ;
$_GroupsUnit_Tab_Count = 0 ;
while( $_GroupsUnit_Tab_Count < $_GroupsUnit_Number_of_Tabs ) &_GroupsUnit_Save_Loop;
}

_GroupsUnit_Save_Loop {
$_GroupsUnit_Tab_Count == 0 ? setpref( INT, "k-meleon_GroupsUnit.".$_GroupsUnit_Name.".Cnt", $_GroupsUnit_Number_of_Tabs ) :0; 
id(ID_TAB_NEXT) ;
setpref( STRING, "k-meleon_GroupsUnit.".$_GroupsUnit_Name.".".$_GroupsUnit_Tab_Count, $URL );
$_GroupsUnit_Tab_Count = $_GroupsUnit_Tab_Count + 1 ;
}

_GroupsUnit_RunCode_Load{
$_GroupsUnit_Name = prompt("Enter name of group to load.", "GroupUnit Name (load)");
$_GroupsUnit_Number_of_Tabs = getpref( INT, "k-meleon_GroupsUnit.".$_GroupsUnit_Name.".Cnt");
$_GroupsUnit_Tab_Count = 0 ;
while( $_GroupsUnit_Tab_Count < $_GroupsUnit_Number_of_Tabs ) &_GroupsUnit_Load_Loop;
}

_GroupsUnit_Load_Loop{
$_GroupsUnit_URL = getpref(STRING, "k-meleon_GroupsUnit.".$_GroupsUnit_Name.".".$_GroupsUnit_Tab_Count );

###  Extra code for special user agents
if ($_GroupsUnit_URL == "http://www.perigee.net/~jmd8421r/"winking smiley {
    setpref( STRING, "general.useragent.override", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18");
	alert( "User agen string change", "Force a wait", EXCLAIM) ;
	$_GroupsUnit_URL == "http://www.perigee.net/~jmd8421r/"; ? alert(getpref( STRING, "general.useragent.override"), "Agent DEBUG", INFO); : 0;
	}
	###  End extra code for user agents

opentab( $_GroupsUnit_URL ); 
$_GroupsUnit_Tab_Count = $_GroupsUnit_Tab_Count + 1 ;
}

_GroupsUnit_RunCode_Delete{
$_GroupsUnit_Name = prompt("Enter name of group to delete.", "GroupUnit Name (delete)");
$_GroupsUnit_Number_of_Tabs = getpref( INT, "k-meleon_GroupsUnit.".$_GroupsUnit_Name.".Cnt");
$_GroupsUnit_Tab_Count = 0 ;
while( $_GroupsUnit_Tab_Count < $_GroupsUnit_Number_of_Tabs ) &_GroupsUnit_Delete_Loop;
}

_GroupsUnit_Delete_Loop{
$_GroupsUnit_Tab_Count == 0 ? delpref("k-meleon_GroupsUnit.".$_GroupsUnit_Name.".Cnt");
delpref("k-meleon_GroupsUnit.".$_GroupsUnit_Name.".".$_GroupsUnit_Tab_Count);
$_GroupsUnit_Tab_Count = $_GroupsUnit_Tab_Count + 1 ;
}

_GroupsUnit_BuildMenu{
# add another option to the File menu
$_GroupsUnit_Popm = "GroupsUnit" ;
$kTabs?setmenu("&File",popup,$_GroupsUnit_Popm,4):0;
$kTabs?setmenu($_GroupsUnit_Popm,macro,"Save a group",_GroupsUnit_RunCode_Save,1):0;
$kTabs?setmenu($_GroupsUnit_Popm,macro,"Load a group",_GroupsUnit_RunCode_Load,2):0;
$kTabs?setmenu($_GroupsUnit_Popm,macro,"Delete a group",_GroupsUnit_RunCode_Delete,3):0;
}

$OnInit=$OnInit."_GroupsUnit_BuildMenu;";
$macroModules=$macroModules."GroupsUnit;";




Options: ReplyQuote
Re: macro help(variables)
Posted by: JujuLand
Date: January 09, 2009 09:06AM

I was asking for a native managment of white lists, which allows to keep the used userstring for the desired sites.

No answer, but I think it would be a great improvement. No more problems with all the webmail, and such websites ...

A+



Mozilla/5.0 (x11; U; Linux x86_64; fr-FR; rv:38.0) Gecko/20100101 Ubuntu/12.04 K-Meleon/76.0


Web: http://jujuland.pagesperso-orange.fr/
Mail : alain [dot] aupeix [at] wanadoo [dot] fr



Ubuntu 12.04 - Gramps 3.4.9 - Harbour 3.2.0 - Hwgui 2.20-3 - K-Meleon 76.0 rc



Options: ReplyQuote
Re: macro help(variables)
Posted by: disrupted(unlogged)
Date: January 09, 2009 10:56AM

thanks james, i'll work on your macro and see what i can do.
me too alain, even though i don;t use webmail but every now and then i encounter bad sites that say not supported browser or don't say it and give limited features.. and as gunter has said, ours is a minority browser.

i hope i can write something good in the end.. i'm still in my very beginnings with macros but i know with everybody's help.. this may work out.

Options: ReplyQuote
Re: macro help(variables)
Posted by: desga2
Date: January 09, 2009 11:42AM

I think this is possible, because $URL var change when page is loaded (finished), but $URLBAR change ever you change the URL bar address contents. For this I used $URLBAR instead $URL in Groups2.kmm macro code.

I try something like this (included JujuLand's whitelist request):

# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
#
# ---------- User Agent AutoSwitcher ---------------------------------------------
#
# Dependencies : main.kmm, useragent.kmm
# Resources : \Tools\whitelist.txt
# Preferences : kmeleon.plugins.macros.AutoSwitcher
# --------------------------------------------------------------------------------

$_AS_pref="kmeleon.plugins.macros.AutoSwitcher";

autoswitcher{
if(getpref(BOOL,$_AS_pref)){
	$__path=getfolder(RootFolder)."\\Tools\\".$whitelist_File; $__data=readfile($__path);
	$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
	if(index($__data, $URLBAR)!=-1){
		setpref(STRING, "general.useragent.override", getpref(STRING, "kmeleon.privacy.useragent1.string"));
		#alert("User agen string change", "Force a wait", EXCLAIM);
		&UserAgent_AlertString;
		open($URLBAR);
		# Restore default UA:
		# macros("UserAgent()");
	}
}
}

UAswitcher{
if(getpref(BOOL,$_AS_pref)){
	$__path=getfolder(RootFolder)."\\Tools\\".$whitelist_File; $__data=readfile($__path);
	$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
	if(index($__data, $URLBAR)!=-1){
		setpref(STRING, "general.useragent.override", getpref(STRING, "kmeleon.privacy.useragent1.string"));
		&UserAgent_AlertString;
		id(ID_NAV_RELOAD);
		# Restore default UA:
		# macros("UserAgent()");
	}
}
}

UArestore{
&UserAgent_ToggleReset;
}

_AS_withelist{
macroinfo=_("Open the withelist of URLs for AutoSwitcher");
$ext="txt"; &getExtensionHandler; $whitelist_File="whitelist.txt";
$__path=getfolder(RootFolder)."\\Tools\\".$whitelist_File; $__data=readfile($__path);
$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
}

_AS_toggle{
macroinfo=_("Enable/disable AutoSwitcher");
menuchecked=getpref(BOOL,$_AS_pref);
togglepref(BOOL,$_AS_pref);
}

autoswitcher_BuildMenu{
getpref(BOOL, $_AS_pref) == ""?setpref(BOOL, $_AS_pref, false):0;
setmenu("Settings",popup,"AutoSwitcher");
setmenu("AutoSwitcher",macro,_("Enable AutoSwitcher"),"_AS_toggle");
setmenu("AutoSwitcher",macro,_("Open WhiteList ..."),"_AS_withelist");
setaccel("ALT VK_RETURN","macros(autoswitcher)");
}

# --------------------------------------------------------------------------------
$OnInit=$OnInit."autoswitcher_BuildMenu;";
$OnLoad=$OnLoad."UAswitcher;";
$OnQuit=$OnQuit."UArestore";
$macroModules=$macroModules."AutoSwitcher;"

K-Meleon in Spanish



Edited 4 time(s). Last edit at 01/09/2009 06:40PM by desga2.

Options: ReplyQuote
Re: macro help(variables)
Posted by: JamesD
Date: January 09, 2009 01:59PM

I like the method from desga2 much better than the one I put forward. I don't like having to re-load the page, but in the absence of a preload event, it is the best we can do.

Options: ReplyQuote
Re: macro help(variables)
Posted by: disrupted
Date: January 09, 2009 05:11PM

i like that method too.. i'll try to work with it, for now it's a bit daunting for me; keeps opening the whitelist in notepad everytime i change address or open new page.

Options: ReplyQuote
Re: macro help(variables)
Posted by: desga2
Date: January 09, 2009 06:37PM

Quote
disrupted
i like that method too.. i'll try to work with it, for now it's a bit daunting for me; keeps opening the whitelist in notepad everytime i change address or open new page.

This can be solved, i created two ways to run this macro function;
1) With OnLoad event: UAswitcher()
2) With Alt+Enter: autoswitcher()

You can change the code to load white list at OnInit event, in autoswitcher_BuildMenu() function for example, and store it in a variable.
Then modify UAswitcher() to compare with this variable instead read whitelist.txt file again.
And let autoswitcher() (Alt+Enter) function to use with force load whitelist.txt file. If you did changed in whitelist.txt file.

autoswitcher() function lost a line code to open URL again with new User Agent string:
autoswitcher{
if(getpref(BOOL,$_AS_pref)){
	$__path=getfolder(RootFolder)."\\Tools\\".$whitelist_File; $__data=readfile($__path);
	$__data==""?&cfg_FileNotFound:exec(sub("%1",$__path,$cmdline));
	if(index($__data, $URLBAR)!=-1){
		setpref(STRING, "general.useragent.override", getpref(STRING, "kmeleon.privacy.useragent1.string"));
		#alert("User agen string change", "Force a wait", EXCLAIM);
		&UserAgent_AlertString;
		open($URLBAR);
		# Restore default UA:
		# macros("UserAgent()");
	}
}
}

P.S.: I added this line in my first post code.

K-Meleon in Spanish



Edited 2 time(s). Last edit at 01/09/2009 06:41PM by desga2.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.