MyMiniMacros - collect your own in here!
Posted by: siria
Date: February 16, 2010 02:55AM

This macro is meant for YOU to collect all sorts of LITTLE macro snippets that YOU like, and pick up new ones over time, when you stumble over them, or just ASK in the forum if you need something special.
Just little mini-macros that aren't worth creating a single kmm-file for each one and clutter the macro list. That means everyone will have a different version of this!
And everyone can post more mini-macros in this thread, for others who might like them.
Below are just a few EXAMPLES that I use myself.

To use it: open notepad, copy the blue text into it and save it as
MyMiniMacros.kmm in the macros folder. Restart browser.


# K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2)
#
# ------------------ MyMiniMacros .kmm -------------- (example 0.1 by Siria) -----------------
# Forum: kmeleon.sourceforge.net/forum/read.php?9,103064
#----------------------------------------------------------------------------
#
# This macro is meant for YOU to collect all sorts of LITTLE macro snippets that YOU like,
# and pick up new ones over time, when you stumble over them, or just ASK in the forum if you
# need something special. Just little mini-macros that aren't worth creating a single kmm-file for
# each one and clutter the macro list. That means everyone will have a different version of this!
#
# MENU:
# If you need a menu entry for a mini-macro, add a line to the "setmenu"-lines at the bottom.
#
# MOUSE GESTURES AND TOOLBAR BUTTONS:
# For mouse gestures new macros must also be added in Tools > Mouse Gestures > Manage actions
# For gestures and for buttons the new command is: macros(macroname)
# (the "macroname" ist the part before the first "{" of each macro)


############### TABS ################

minimacros_movtabprev{
macroinfo="Move tab to the previous window. Page will reload.";
$OpenURL=$URL;
id(ID_CLOSE_TAB);
id(ID_WINDOW_PREV);
opentab($OpenURL);
}
# menu below: setmenu(_kTabs_Detach,macro,"Move tab to previous window",minimacros_movtabprev,-1);

minimacros_PageNewWindow{
macroinfo="Open current page in a new window as copy. Page will reload.";
$OpenURL=$URL;
&OpenURL_InNewWindow;
}
# menu below: setmenu(_kTabs_Detach,macro,"Copy page into new window",minimacros_PageNewWindow,-1);


############## OPEN IN... ################

minimacros_GoPasteNew{
macroinfo="Get Clipboard and open as URL in New Tab/Window";
$OpenURL=getclipboard();
&OpenURL_InNew;
}
# menu below: setmenu(_Go_Clipboard,macro,"Paste And Go in New Page",minimacros_GoPasteNew,"Paste And &Search");


############## PAGE UP/DOWN ################

# For mouse gestures, otherwise not needed (Already on all keyboards, or click on scrollbar):

minimacros_pagedown{$JS_doit="scrollBy(0,scrollByPages(1))";&JS_hndlDoc;}

minimacros_pageup{$JS_doit="scrollBy(0,scrollByPages(-1))";&JS_hndlDoc;}

minimacros_bottom1up{
macroinfo="Scroll to bottom, then 1 page or x pixels up again (handy for some forums)";
&JS_scrollBottom;
$JS_doit="scrollBy(0,scrollByPages(-1))"; &JS_hndlDoc;
# $JS_doit="scrollBy(0,-60)"; &JS_hndlDoc;
}

#############
# (add your own here)


############# MENUS ##############

_MyMiniMacros_BuildMenu{
setmenu(_kTabs_Detach,macro,"Move tab to previous window",minimacros_movtabprev,-1);
setmenu(_kTabs_Detach,macro,"Copy tab into new window",minimacros_PageNewWindow,-1);
setmenu(_Go_Clipboard,macro,"Paste And Go in New Page",minimacros_GoPasteNew,"Paste And &Search");
}
$OnInit=$OnInit."_MyMiniMacros_BuildMenu;";




Edited 4 time(s). Last edit at 02/16/2010 05:01AM by siria.

Re: MyMiniMacros - collect your own in here!
Posted by: SoerenB
Date: February 16, 2010 11:00AM

Hi, siria,

what a bright idea, again!

Shouldn't this be made sticky?

Cheers!
SoerenB

Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: February 21, 2010 06:25PM

Thanks for liking it Soeren smiling smiley

And here come 2 new ones, if anyone has use for it, insert the desired commands into the macro in first posting, and copy the setmenu lines to the others at the bottom (without the comments at beginning of course):

############## IMAGES ################

minimacros_ImgMaxWidth{
macroinfo="
Set max-width for images until next reload (700px, via injectCSS)";
injectCSS(" * img {max-width: 700px !important; }");
}
minimacros_ImgMaxWidthOff{
macroinfo="Reset max-width for images (no limit, via injectCSS)";
injectCSS(" * img {max-width: none !important; }");
}

# in menu "View": setmenu("&View",macro,"Images Max-Width ON",minimacros_ImgMaxWidth);
# in menu "View": setmenu("&View",macro,"Images Max-Width OFF",minimacros_ImgMaxWidthOff);
# in context-menu for images: setmenu(ImageProperties,macro,"Images Max-Width ON",minimacros_ImgMaxWidth);
# in context-menu for images: setmenu(ImageProperties,macro,"Images Max-Width OFF",minimacros_ImgMaxWidthOff);


#-----

minimacros_nobackimg{
menugrayed=!$ImageURL;
macroinfo="
Hide background-image until next reload (via injectCSS)";
injectCSS(" * {background-image: none !important; }");
}

# in menu "Page Properties": setmenu("Page Pro&perties",macro,"Hide Background-Image",minimacros_nobackimg);
# in menu "View": setmenu("Page &Properties",macro,"Hide Background-Image",minimacros_nobackimg);


#-----





Edited 1 time(s). Last edit at 02/21/2010 06:26PM by siria.

Re: MyMiniMacros - collect your own in here!
Posted by: SoerenB
Date: February 21, 2010 07:40PM

Hi, Siria,

are you, with these, beginning to serve that VAST "Style Buttons" extension in digesteable portions? I had not dared to ask...Thanks a lot!

Cheers
SoerenB

Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: February 27, 2010 07:20PM

LOL, not really Soeren grinning smiley Wouldn't make much sense, the new collection would end up being just as vast as the complete Style Buttons macro, just one big unsorted heap...
What works though, is such tiny 1-liners as that Hide-Background macro smiling smiley I think everyone can simply take it as a template, just copy and fill it with some other short CSS stuff....
But am a bit curious, is there anything specific that 'scares you off' from using the 'big' one...? All buttons can be hidden, the editor can be deleted, and the menu is just so vast to make customization easier. Or so I thought ;-)


And here comes another quicky, one that has bothered me for a long time smiling smiley Repair links with wrong beginning! Sometimes there are links that have their first character cropped, so the browser can't open it and shows an error. After a while it gets bothersome to always repair that manually *grmpf*
This macro command can always be used instead of the normal "Open Link" function. It checks if the beginning is okay, then opens the link, otherwise it adds the missing character first and then opens it tongue sticking out smiley The last line "&OpenURL_InNew" can be changed how you like it, e.g. ..._InBg for background.

If anyone has use for it, insert it into the macro in first posting, and copy the setmenu line to the others at the bottom (without the comments at beginning of course):

#-----

minimacros_RepairLinkURL{
# Repair links with wrong beginning. Seems to be a fashion in some forums or sites to crop first character ;-)
$OpenURL=$LinkURL;
index($LinkURL,"ttp:")==0 ? $OpenURL="h".$LinkURL : 0;
index($LinkURL,"ttps:")==0 ? $OpenURL="h".$LinkURL : 0;
# Next one may really need "ww.", but it's just about always an (intentional?) typo. You may disable line with #
index($LinkURL,"ww.")==0 ? $OpenURL="w".$LinkURL : 0;
&OpenURL_InNew;
}

# in context-menu for links: setmenu("LinkOpen",macro,"Open In New - Repair Prefix",minimacros_RepairLinkURL,-1);
# Tip: Use "macros(minimacros_RepairLinkURL)" in mouse gesture instead of ID_OPEN_LINK_IN_NEW_TAB


#-----


Re: MyMiniMacros - collect your own in here!
Posted by: caktus
Date: March 03, 2010 11:29PM

@siria

As SoerenB alluded to, "what a bright idea, again!"

Can this actually be used for ALL macros? Is there a size limit to a text/macro file?

Thanks a bunch.

Charlie

~~If it ain't broke, why screw it up?~~


Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: March 05, 2010 02:25AM

Thanx Charlie grinning smiley
Sure you can add what you want to it, it's meant exactly for this. I'd just recommand making a backup copy of it first, named ...kmm.bak, just in case... ;-) The error-console (in Tools menu) is quite helpful for checking syntax, although it often overlooks something too.

Never heard of a size limit smiling smiley My biggest kmm has 45kB so far, over 800 lines, so guess no need to worry cool smiley

Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: March 05, 2010 09:27PM

And another... cool smiley
Override webmaster settings for color of visited links.

KM does have a pref for visited links, just type "about:config" and look for "color". It's just that this is only used if a webmaster has not defined an own color, otherwise he has priority. There is also a setting in Preferences to enforce own colors, but that goes for ALL text styles, not just visited links.

Now this macro will enforce your own color for visited links if you click the button, and remains active until you click it again, or until the browser is closed.
Like the other CSS macro above, you can take this as template for your own modifications, the CSS code in the injectCSS-line can be what you wish, it just must not have any line breaks inside. Didn't try a big one, but in theory that's no prob, just like bookmarklets CSS can be one long string with glued-together lines ;-)
You can even inject whole external css-files, that's probably better for bigger ones. Example:
injectCSS(readfile(getfolder(RootFolder)."\\styles\\stylebtn_cust1.css));

If you like this, insert it into the macro in first posting, and copy the setmenu line to the others at the bottom (without the comments at beginning of course):

############## PAGE STYLE ################

# Override webmaster settings for color of visited links. Setting remains until you click again or browser restart.
# Set here the default at browser start (and color is below in injectCSS-line):
$_mini_csslinkv="false";

minimacros_css_linksvisited_set{
macroinfo="Display visited links in my color (via injectCSS). Color and startup setting in kmm-file.";
menuchecked=($_mini_csslinkv=="true");
if ($_mini_csslinkv=="false") { $_mini_csslinkv="true";
&minimacros_css_linksvisited;
$OnLoad=$OnLoad."minimacros_css_linksvisited;";}
else { $_mini_csslinkv="false";
$OnLoad=sub("minimacros_css_linksvisited;","",$OnLoad);}
}
minimacros_css_linksvisited{
injectCSS("a:visited , a:visited * {color: purple !important;}");
}

# in menu "Page Properties": setmenu("Page Pro&perties",macro,"Visited links in my color",minimacros_css_linksvisited_set,-1);
# in menu "View": setmenu("Page &Properties",macro,"Visited links in my color",minimacros_css_linksvisited_set,-1);
# in menu "Stylesheets" if exists: setmenu("Stylesheets",macro,"Visited links in my color",minimacros_css_linksvisited_set,-1);
# button-command in toolbars.cfg: macros(minimacros_css_linksvisited_set)

#-----



Edited 5 time(s). Last edit at 03/05/2010 11:02PM by siria.

Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: March 13, 2010 09:08PM

Sometimes an image is hard to get a hold of - if the image context menu is missing. Such an image may not even appear in the list of all images in a page.
Meanwhile I know that one can hover the mouse over it > click page properties> Background Image! But to make things easier to remember, and to get tabs instead of windows, here's another tiny harmless mini-macro, almost too embarassing to post smiling smiley

This macro creates a permanent entry in the PAGE context menu: "View Image in new Tab". If you like, also in the image context menu, just to open normal pics in tabs too.

Example page: the image left of the title: http://www.getpersonas.com/en-US/persona/473

Tip: Put this on a mouse gesture, e.g. Shift+Up: macros(minimacros_viewimage)
It works for all images, normal or HIDDEN alike tongue sticking out smiley

To use it, insert it into the macro in first posting, and copy the setmenu lines to the others at the bottom (without the comments at beginning):

#-----

minimacros_viewimg{
menugrayed=!$ImageURL;
macroinfo="View Image in new Tab (shortcut to Page-Properties > Background Image). Easier to find if no context menu for images.";
$OpenURL=$ImageURL; &OpenURL_InNew;
}

# in context-menu for Page: setmenu(DocumentPopup,macro,"View Image in new Tab",minimacros_viewimg);
# in context-menu for Images: setmenu(ImageView,macro,"View Image in new Tab",minimacros_viewimg,"Zoom I&n");


#-----


Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: March 13, 2010 10:29PM

Uhm, a second in one day *blush* tongue sticking out smiley
Some day I hope to update my useragent2-macro, but for now just as mini-macro:

Edit custom user agents list, via a new entry in the UserAgents menu.
Clicking it opens the text file with the listing. And this list will not be lost anymore, it will appear in new profiles and also after overwriting KM with a newer version. Just for completely new installs, please remember to copy over this file.

You must first create this list: Go to K-Meleon/defaults/pref/I10n.js, make a copy of it, name it "I10n_useragentsmore.js", open it with notepad and delete all other stuff. Then modify the UAs into your additional useragents, and add more if you like.

IMPORTANT:
Check the counter numbers! Make sure they have no 'holes' (1,2,5,...), or the rest of the entries will not show up anymore in the menu. On the other hand if some are double, e.g. 1-4 in the default I10n.js, and 2-8 in this extra sheet, than the duplicates seem to be ignored, but fortunately don't seem to cause major errors.

UA examples and links: http://kmeleon.sourceforge.net/forum/read.php?4,104347

#-----

minimacros_EditUserAgents{
macroinfo"Edit custom user agents list '\defaults\pref\I10n_useragentsmore.js' To first create it, copy example from I10n.js (notepad)";
$mini_UAcustomprefs=getfolder(RootFolder)."\\defaults\\pref\\I10n_useragentsmore.js";
$ext="txt"; &getExtensionHandler;
exec(sub("%1",$mini_UAcustomprefs,$cmdline));
}

# in User Agent menu: setmenu("&User Agent",macro,"CUSTOM edit entries",
minimacros_EditUserAgents,-1);


#-----



Edited 2 time(s). Last edit at 03/14/2010 02:52PM by siria.

Re: MyMiniMacros - collect your own in here!
Posted by: ndebord
Date: March 18, 2010 09:47AM

Quote
siria
Uhm, a second in one day *blush* tongue sticking out smiley
Some day I hope to update my useragent2-macro, but for now just as mini-macro:

Edit custom user agents list, via a new entry in the UserAgents menu.
Clicking it opens the text file with the listing. And this list will not be lost anymore, it will appear in new profiles and also after overwriting KM with a newer version. Just for completely new installs, please remember to copy over this file.

You must first create this list: Go to K-Meleon/defaults/pref/I10n.js, make a copy of it, name it "I10n_useragentsmore.js", open it with notepad and delete all other stuff. Then modify the UAs into your additional useragents, and add more if you like.

IMPORTANT:
Check the counter numbers! Make sure they have no 'holes' (1,2,5,...), or the rest of the entries will not show up anymore in the menu. On the other hand if some are double, e.g. 1-4 in the default I10n.js, and 2-8 in this extra sheet, than the duplicates seem to be ignored, but fortunately don't seem to cause major errors.

UA examples and links: http://kmeleon.sourceforge.net/forum/read.php?4,104347

#-----

minimacros_EditUserAgents{
macroinfo"Edit custom user agents list '\defaults\pref\I10n_useragentsmore.js' To first create it, copy example from I10n.js (notepad)";
$mini_UAcustomprefs=getfolder(RootFolder)."\\defaults\\pref\\I10n_useragentsmore.js";
$ext="txt"; &getExtensionHandler;
exec(sub("%1",$mini_UAcustomprefs,$cmdline));
}

# in User Agent menu: setmenu("&User Agent",macro,"CUSTOM edit entries",
minimacros_EditUserAgents,-1);


#-----

Siria,

Don't quite get this...

I10n_useragentsmore.js

The above file contains your list of user agent strings, no?

The mini macro is this?

-----------

minimacros_EditUserAgents{
macroinfo"Edit custom user agents list '\defaults\pref\I10n_useragentsmore.js' To first create it, copy example from I10n.js (notepad)";
$mini_UAcustomprefs=getfolder(RootFolder)."\\defaults\\pref\\I10n_useragentsmore.js";
$ext="txt"; &getExtensionHandler;
exec(sub("%1",$mini_UAcustomprefs,$cmdline));
}
# in User Agent menu: setmenu("&User Agent",macro,"CUSTOM edit entries",
minimacros_EditUserAgents,-1);

-----------

The above is a KMM file??? IF so, then what do you call it? And how is it started up?

Tks.

N

Re: MyMiniMacros - collect your own in here!
Posted by: siria
Date: March 19, 2010 03:53AM

The explanation is in the first posting, ndebord smiling smiley
It gives the structure into which the various mini-macros can be copied, like books into a book shelf. Basically the one thing they use all in common, is the buildmenu-collection at the bottom, in there all the setmenu-lines should be copied. If not, the mini-macros still work but have no menu entry, so could only be used for toolbar buttons, shortcuts or mouse gestures ;-)

By the way the name for a kmm-file doesn't matter in the least for the function. All that matters are the macro commands inside it that have the "{" right after them.
Taking the above as example, the command (or startup command ;-) for buttons/shortcuts/gestures would simply be "macros(minimacros_EditUserAgents)"

Those blue lines in your quote could really just be copied into a new text file, saved as is (without any additions) under anyname.kmm in a macros folder and could be used for buttons etc. - just wouldn't show up in any menu.

But usually one wants also menu entries, and that's the job of the buildmenu-macro, at the very bottom of nearly all kmm-files. Only that one needs to be called automatically at startup of the browser, which is done with that "OnInit"-line smiling smiley
I remember I was rather confused too in the beginning, until I realized that a kmm-file is called a "macro", but also the single commands (menu entries) in it are "macros"!



Edited 3 time(s). Last edit at 03/19/2010 04:06AM by siria.

Re: MyMiniMacros - collect your own in here!
Posted by: ndebord
Date: March 19, 2010 10:45AM

Quote
siria
The explanation is in the first posting, ndebord smiling smiley
It gives the structure into which the various mini-macros can be copied, like books into a book shelf. Basically the one thing they use all in common, is the buildmenu-collection at the bottom, in there all the setmenu-lines should be copied. If not, the mini-macros still work but have no menu entry, so could only be used for toolbar buttons, shortcuts or mouse gestures ;-)

By the way the name for a kmm-file doesn't matter in the least for the function. All that matters are the macro commands inside it that have the "{" right after them.
Taking the above as example, the command (or startup command ;-) for buttons/shortcuts/gestures would simply be "macros(minimacros_EditUserAgents)"

Those blue lines in your quote could really just be copied into a new text file, saved as is (without any additions) under anyname.kmm in a macros folder and could be used for buttons etc. - just wouldn't show up in any menu.

But usually one wants also menu entries, and that's the job of the buildmenu-macro, at the very bottom of nearly all kmm-files. Only that one needs to be called automatically at startup of the browser, which is done with that "OnInit"-line smiling smiley
I remember I was rather confused too in the beginning, until I realized that a kmm-file is called a "macro", but also the single commands (menu entries) in it are "macros"!

Siria,

Much thanks for the explanation. Absolutely zero time available to play with the macros, but do appreciate the user agents, which I copied into that file you mentioned and now have availble in Tools/User Agent.

N

K-Meleon forum is powered by Phorum.