Improvement requests :  K-Meleon Web Browser Forum
Use this forum to talk about a feature you're missing. 
Feature request: check duplicate page opening
Posted by: rodocop
Date: May 23, 2015 05:39PM

This request is from one of the russian comrades:

he asks for the ability to check while opening link whether the same address is already open in some other tab;

if yes - switch to that tab (not opening duplicate)
if no - open tab in usual way.


I don't know how this could be implemented - obviously not by KMM. But if someone could write some js-stuff or something else...



Edited 1 time(s). Last edit at 05/23/2015 05:39PM by rodocop.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JamesD
Date: May 24, 2015 01:24AM

@ rodocop

This does not meet all the criteria but may be a starting point. It requires a right click choice of "Open In Existing Tab". The macro system does not have a way to obtain a click until the on load event.

I forced a new tab when existing not found, but that can be improved. This version will only test in the current window.

chkforexist.kmm

#  K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage2)
# File name: chkforexist.kmm
# ---------- Check for tab with same URL as link then view existing or open new tab
# ---------- JamesD  2015-05-23

_chkforexist_Search {
macroinfo = _("Open link in existing tab if URL match found.");
$_chkforexist_tcnt = 0; $_chkforexist_link  = $LinkURL ;
while($_chkforexist_tcnt < $TabNumber ) {
  id(ID_TAB_NEXT);
  $_chkforexist_link==$URL?$_chkforexist_tcnt=$TabNumber+1:$_chkforexist_tcnt=$_chkforexist_tcnt+1; 
  }
$_chkforexist_tcnt ==  $TabNumber ? id(ID_OPEN_LINK_IN_NEW_TAcool smiley :0;
}

_chkforexist_BuildMenu {
	# add another option to LinkOpen menu
       setmenu("LinkOpen",macro,"Open In Existing Tab","_chkforexist_Search");
}

## - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$OnInit=$OnInit."_chkforexist_BuildMenu;";
$macroModules=$macroModules."chkforexist;"; 


Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: siria
Date: May 24, 2015 06:37AM

Interesting request, and nice macro smiling smiley

For convenience the user could add it on a keyboard shortcut in profiles accel.cfg, e.g. for middleclick:
MButton = macros(_chkforexist_Search)

OR better directly in the kmm itself, between the last } and ## :
_chkforexist_setaccel {
setaccel(MButton,"macros(_chkforexist_Search)");
}
$OnSetup=$OnSetup."_chkforexist_setaccel;";


(all in theory by reading only, have tested nothing yet)

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JamesD
Date: May 24, 2015 01:38PM

siria

Yes, I had thought of three improvements needed for the original version. One was your idea of a set of accelarator keys. I am just never sure which keys are already in use.

The second was a loop outside the tabs loop which would cycle through all the windows, and the third is a way to open the link in the same manner as would happen if the user just clicked on the link.

Is there not some 'open method' items within main.kmm? I must do some research. If all three 'improvements' work, I think it will meet the criteria of the request.

Give some thought to the label of the menu item. Should it remain "Open In Existing Tab" or change to "Open In Existing Tab?". We are not certain that there is an 'existing' tab.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: siria
Date: May 24, 2015 03:42PM

There are just too many user options to consider, which sure is partly possible, but makes the macro rather complicated to write. E.g. about normal left-clicks we can do nothing anyway, that will always open links in the current tab. And IMO that's fine.
So that leaves to open the link in new TAB, or new WINDOW, either FORE- or BACKground.... ouf...
Yes there are some options in main.kmm how to open links, but we still don't know if the user prefers to open links with Shift, Ctrl, or middleclick, which is then again combined with a bunch of different actions, ouf...
Uh oh... and those settings in main.kmm also define how to open "typed URLs", bookmarks, selected text!!
Perhaps much of that can be done with lots of work, nearing perfection, but without me tongue sticking out smiley ;-)

So I just took the most simple approach:
most users seem to prefer opening links with MIDDLE-click in a new tab (or background tab?), and that's it. Done :cool:
No bookmark options, no selected or typed text, those should be less frequent uses anyway.
Same for multiple windows.

Another window-loop is probably easy, but if one uses tabs, I don't expect them to have multiple windows, or like me, only to organize different subjects, each with lots of tabs, but not related. So why.

Okay, one thing that would still be important is to check if middle-click is set to open in new or background tab, that's defined somewhere in accel.kmm and stored in prefs. But personally, I'd rather not get lost further in that jungle ;-)

Naming, yeah always a prob... perhaps something like.... Open In New (or jump to existing)



Edited 1 time(s). Last edit at 05/24/2015 03:57PM by siria.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: siria
Date: May 24, 2015 04:17PM

Sigh, can't stop myself from playing, so checked that Foreground/Background pref for middle-clicks. Looks like all except the native KM-setting is to use background:
http://kmeleon.sourceforge.net/wiki/FAQ#mouseaccels

So a check could be done like this, in another sub-macro:
getpref(STRING,$Accel_MouseConfig) ? obenbgtab($LinkURL) : opentab($LinkURL);

Should work as expected as long as a user hasn't changed native KM middleclick to "background" via Edit>Config>Accelerators :cool:
(again, have nothing tested, all just theory)



Edited 2 time(s). Last edit at 05/24/2015 10:27PM by siria.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: rodocop
Date: May 24, 2015 04:55PM

About name:

"Open with existance check" ?

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: siria
Date: May 24, 2015 06:55PM

hmm... if I didn't know what it's about that would sound like:
Check if the link exists (on the server), otherwise don't open...

Another: duplicate check...

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JamesD
Date: May 24, 2015 09:36PM

siria and rodocop

It quickly became more complex than I thought I had time to spend right now. The version below does tabs in the current window only. It does have the accelerator key set. I used rodocop's label.

It does follow the default for middle button operation. The menu is better placed and an attempt has been made to follow macro writing guidelines.

The 7Zip file is correct for extraction to the user's KM root folder.

Thanks for all the input.

https://dl.dropboxusercontent.com/u/1522294/chkforexist.7z

Please let me know if it meets expectations or not.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: rodocop
Date: May 24, 2015 11:31PM

Many thanks, James!

I will inform about user feedback.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JamesD
Date: May 28, 2015 04:33PM

I need a little help. Somewhere in the wiki there is some information on what environment is available to a macro. The statement has to do with where the macro starts. I have looked but I can't find the statement. The statement says something about the version of KM when there was a change to this enviornment. That part of the statement is not important, but it may help someone identify the statement.

The problem that I have encountered is that when my new chkforexist runs, it correctly sees the URL for each tab in the current window. However when it processes the ID_WINDOW_NEXT command it still sees the URLs for the tabs in the first window. It does not see the URLs for the tabs in the second window.

I don't want to report this as a bug until I am sure what that statement says.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: rodocop
Date: May 28, 2015 07:13PM

The only thing that i can suggest is the MacroLanguage2 page which is full of remarks looking like 'since version x.x'

But I can see this page only in russian ;-)

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: siria
Date: May 28, 2015 10:37PM

Quote
rodocop
But I can see this page only in russian ;-)

Ah no, you kidding, that would mean that everyone with non-english language would only see ~ten year old page versions?! :O
Actually one can switch the language any time, via the language flags in the left green bar. The prob is just, which flags are visible depends from the languages chosen in F2>Page Display>languages, and if someone has no EN in his list then this page is a prehistoric mess - and its already much outdated even in english sad smiley
MO there should be a permanent english flag available.

Those flags just add such an ending to the URL:
http:/ /kmeleon.sourceforge.net/........&switchlang=en

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JohnHell
Date: May 28, 2015 11:22PM

Quote
siria
Quote
rodocop
But I can see this page only in russian ;-)

Ah no, you kidding, that would mean that everyone with non-english language would only see ~ten year old page versions?! :O
Actually one can switch the language any time, via the language flags in the left green bar. The prob is just, which flags are visible depends from the languages chosen in F2>Page Display>languages, and if someone has no EN in his list then this page is a prehistoric mess - and its already much outdated even in english sad smiley
MO there should be a permanent english flag available.

Those flags just add such an ending to the URL:
http:/ /kmeleon.sourceforge.net/........&switchlang=en

It is, don't worry. A few months back I tried the switchlang and the flagas at the left menu aren't shown for all people.

For example, the German see the English and German flag; French the French and English flag; Me, spanish, the Spanish and English flag; and so on.

Also, talking about the wiki, if it is available (someone created it), you can type the URL with the country/language ISO code at the end of the URL.

http://kmeleon.sourceforge.net/wiki/MacroLanguage2Ru
http://kmeleon.sourceforge.net/wiki/MacroLanguage2De
http://kmeleon.sourceforge.net/wiki/MacroLanguage2Es
.
.
.



Edited 1 time(s). Last edit at 05/28/2015 11:22PM by JohnHell.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: siria
Date: May 28, 2015 11:37PM

Quote
JohnHell
Also, talking about the wiki, if it is available (someone created it), you can type the URL with the country/language ISO code at the end of the URL.
http://kmeleon.sourceforge.net/wiki/MacroLanguage2Ru
http://kmeleon.sourceforge.net/wiki/MacroLanguage2De
http://kmeleon.sourceforge.net/wiki/MacroLanguage2Es

Yes, that works for reading, but caution when editing! The wiki is extremely tricky when editing other languages. If I don't pay extreme attention it creates a single page with *2* language endings! Managed that 1-2x myself accidentally, IIRC if the main browser language wasn't the same as the ending-language, but it's been awhile, not quite sure anymore.
The prob is, new pages can never be deleted anymore :-/



Edited 1 time(s). Last edit at 05/28/2015 11:39PM by siria.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JamesD
Date: May 29, 2015 10:58AM

I wrote MacroLanguage2 in English. I made no translations.

I tried the link posted above and got this:
Quote

MacroLanguage2De

This page does not yet exist, please click on EditThisPage if you'd like to create it.


Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: rodocop
Date: May 29, 2015 01:08PM

I've got the same - and also for DE.

But RU exists for me (someone from Russian team had translated it years ago)

And also I was trying to update russian translation of pages, but got lost in unexpected behaviours of our wiki.

So I refused to do it. We need some more friendly way to contribute into translation of our KB (knowledge base).



Edited 2 time(s). Last edit at 05/29/2015 01:10PM by rodocop.

Options: ReplyQuote
Re: Feature request: check duplicate page opening
Posted by: JohnHell
Date: May 29, 2015 03:51PM

Guys, there were examples, I knew they didn't exist some before I posted the URLs above.

BTW, the http://kmeleon.sourceforge.net/wiki/MacroLanguage2En (for english) won't exist as it is the default and base page and, of course, in english.

When switchlang is with "en", my guess, it doesn't add the country code, just loads the wiki page.

The Wiki Markup is not hard, it has some differences with the current version used in Wikipedia, but once you read the link to the help from the "edit pages" is easy to understand. And there is no harm to try any code as unless you click on save you can preview the results for endless tries.


But all this is OffTopic. Going OnTopic I have no idea JamesD, about why get the tabs from the original window. But my guess is that they are locked to the window (I use windows, so easy to guess) that calls it.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.