Extensions :  K-Meleon Forum
All about K-Meleon extensions. 
Find in page: searchWwwInPage (test2)
Posted by: siria
Date: October 18, 2016 03:24AM

This is a 2nd function test before adding more GUI stuff (or give it up)

see also this improvement request:
http://kmeleonbrowser.org/forum/read.php?4,139963,139978#msg-139978

Prob:
Not sure if macros can now use the clipboard again for pasting, that function was broken for years (incl. KM1.6). Please test and tell which KM-version works? Or which not? Perhaps only KM76 has a chance? Or perhaps it also depends from the OS?

Function:
When you call this macro (currently by CTRL+SHIFT+F) it shall open the native Find-in-page bar AND automatically paste inside the last searchtext from a web search, like google etc.
By default the URL key is "/search?q=", until next "&"
This can be changed in about:config. A longer description is inside, file readable in notepad.

Attachments: searchWwwInPage.kmm (6.1 KB)  
Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: JamesD
Date: October 18, 2016 04:47AM

siria

Perhaps I do not test correctly, but in KM 75.1 and in KM 76RC2, I do not get any value in the "Find in page" field.

I tested this way.
1) Copy macro to macros folder in my profile.
2) Start KM and saw the new macro notice.
3a) Type one word in the search input field.
3b) Type one work in URL bar.
4a) Click OK to run search and get results in a new tab.
4b) Press Enter to run search and get results in the same tab.
5) Use Ctrl Shift F to show Find in page. No value shows.

Paste from clipboard seems to work for me when I did the Selected text test.

Bearing in mind my age, etc, take nothing I say as TRUE without verifying yourself.

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: JamesD
Date: October 18, 2016 07:01AM

Quote
siria from comment in macro
not sure about macros lineorder bug: can setclip sw1 work if value deleted at almost same time??

I don't think it is a problem. The following works for me.

_findtry_oper1 {
macroinfo = "Run the findtry test." ;
$_findtry_CurrClip = getclipboard();
id(ID_EDIT_COPY);
id(ID_EDIT_FIND);
id(ID_EDIT_PASTE);
setclipboard($_findtry_CurrClip);
id(ID_EDIT_FINDNEXT);
alert($_findtry_CurrClip." and ".getclipboard(), "Check clipboard", INFO);
}

A previous copy's value was in the alert twice and the current selected text appears in the Find in page.

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: JamesD
Date: October 18, 2016 03:17PM

I think I may know the problem. It is the urlkey. My search from DuckDuckGo is "https://duckduckgo.com/?q=copper&ia=web";. The default key is "/search?q=".

I will edit my config and change to "/?q=".

Edit:: That works. I have item in Find in Page field.

Edit #2 :: Suggestion

Check pref "kmeleon.general.searchEngine" after line 47 "$_x>"" ?" to choose default key. Note, I have no idea how many different engines might appear. I see that Bing and Google use the original key.

Oh My Gosh! What happens when a user runs the current search with a engine that is not his/her general engine?



Edited 2 time(s). Last edit at 10/18/2016 03:39PM by JamesD.

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: siria
Date: October 19, 2016 03:27AM

The funny thing is, your described KM reactions sound very much like those of KM1.6 ;-) And there I strongly suspected my poor old system again, hanging on so bravely - but in nearly all cases it's accused wrongly.

Using different search engines and other user stuff is no major worry, can easily add a few more hardcoded checks for common strings. But all is just a waste of time if the key function doesn't work right.

Currently my impression is (with KM1.6), that "setclipboard" is the culprit and has some encoding bug. Set and Get are definitely allowed, as a test alert shows. And while it mostly doesn't paste anything at all, sometimes it actually does - but wrong text! Not the macro text, instead some previously manually copied string. On the other hand, pasting into a text file shows the macro string again right. And sometimes it only works to paste into utf8 textfile but not in an ansi-file (or was it the other way around?), sometimes into none, or into all. Grmpf. Still too confusing which circumstances work or not.

Have again tried to find alternative methods, e.g. a search for "firefox javascript clipboard" brought up some interesting finds, but no solution yet.

Attention when testing: it matters how the clipboard gets filled. It must be a variable inside the macro itself, not selected text on a page.

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: Tomas Herrmann
Date: October 20, 2016 06:38PM

Quote
siria

Function:
When you call this macro (currently by CTRL+SHIFT+F) it shall open the native Find-in-page bar AND automatically paste inside the last searchtext from a web search, like google etc.
By default the URL key is "/search?q=", until next "&"
This can be changed in about:config. A longer description is inside, file readable in notepad.

Sorry, it seems to be not working on my PC. CTRL-SCHIFT-F invokes the Find-in-page field, but there isnĀ“t anything pasted as websearch - or do I have to prepair anything first?
Tomas

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: JamesD
Date: October 21, 2016 12:17AM

It depends. If your search engine uses the "urlkey" like Google and Bing, then it should work. However, if you use another search engine then the "urlkey" might be different.

I use DuckDuckGo and my "urlkey" is "/?q=" instead of the "/search?q=" that is automaticly included in the test version of the macro. If using DuckDuckGo change the following pref.

user_pref("kmeleon.plugins.macros.searchWwwInPage.urlkey", "/?q=");

Before I assume too much, you must run a search first, and stay on the results page prior to using the CTRL-SHIFT-F. If your engine is other than these, run a search and look on the URL bar for the probable key string.

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: siria
Date: October 21, 2016 01:36AM

Thanks for feedback!
Looks like macro-pasting into this field works on hardly ony KM version yet, and find no workaround so far sad smiley
Which KM-version did you use?

No there shouldn't be anything to prepare. Except of course running 1 initial search for storing a first search text. It gets stored as soon as the search page has stopped loading, that's how macros work. Afterwards that text will be remembered across sessions until next search.
And of course, as James said, using either a search engine with that keyword in the URL or changing that keyword in about:config

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: Tomas Herrmann
Date: October 25, 2016 05:55PM

Hi JamesD,
what would be the "urlkey" for ixquick? could you tell me?
Tomas

Options: ReplyQuote
Re: Find in page: searchWwwInPage (test2)
Posted by: JamesD
Date: October 25, 2016 08:04PM

I used "horses" without the quotes and the URL returned was:

https://www.startpage.com/do/search

They submit your search to Google and strip out some stuff. I don't know.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.