nick
March 1, 2023, 6:23pm
1
For @kxxc :
// #popclip
// { name: 2x Search, lang: js }
const query = encodeURIComponent(popclip.input.text);
popclip.openUrl("https://example1.com/?q=" + query);
popclip.openUrl("https://example2.com/?q=" + query);
(The above block is an extension snippet - select it then click “Install Extension” in PopClip.)
To search more sites, just add more lines.
4 Likes
kxxc
March 1, 2023, 7:06pm
2
yees! thank you
but looks like these lines no longer working on js code, haha…
icon: iconify:tabler:square-rounded-number-4
requirements: [text, “!urls”]
after: copy-selection
nick
March 1, 2023, 7:08pm
3
Post the whole thing for me so I can take a look.
BTW, when posting the forum you can write ``` on the line before and after the code to format it as a code block
2 Likes
kxxc
March 1, 2023, 7:18pm
4
Gave me a shaking X feedback
// { name: test, lang: js }
icon: iconify:tabler:square-rounded-number-4
requirements: [text, "!urls"]
const query = encodeURIComponent(popclip.input.text);
popclip.openUrl("https://www.apple.com/tw/search/" + query);
popclip.openUrl("https://www.youtube.com/results?search_query=" + query);
after: copy-selection
nick
March 1, 2023, 7:25pm
5
Nice job with the ```
So the extension has two parts, the settings and the code, which need to be kept separate.
The extension settings go in the in the top part, with //
before each line, like this:
// #popclip
// name: test
// lang: js
// icon: iconify:tabler:square-rounded-number-4
// requirements: [text, "!urls"]
// after: copy-selection
const query = encodeURIComponent(popclip.input.text);
popclip.openUrl("https://www.apple.com/tw/search/" + query);
popclip.openUrl("https://www.youtube.com/results?search_query=" + query);
1 Like
kxxc
March 1, 2023, 7:39pm
6
I’m alive again! thank u vm!
so many ways in PopClip so much mystery.
every Mac user should use it
2 Likes
live
October 8, 2023, 6:47am
7
@nick
I made some changes and added the ‘alternate URL’ parameter, but it doesn’t seem to work. Did I make any mistakes?
// PopClip
// name: Twitter
// lang: js
// icon: iconify:bi:twitter
// requirements: [text, “!urls”]
// after: copy-selection
const query = encodeURIComponent(popclip.input.text);
url: https://twitter.com/search?q= *** lang:zh-cn
alternate url:
popclip.openUrl(“https://twitter.com/search?q= ” + query);
popclip.openUrl(“https://twitter.com/search?q= ” + query + " filter:follows");
nick
October 8, 2023, 3:31pm
8
It isn’t clear from the snippet you posted what you’re trying to achieve. Please describe in words what want the extension to do.
live
October 10, 2023, 6:09am
9
I’m sorry, my previous description was not clear enough. What I hope to achieve is:
By default, when I click, it performs a default search:
https://twitter.com/search?q= *** lang:zh-cn
When I hold down the ‘Option’ key and click, it opens two links simultaneously for searching:
https://twitter.com/search?q= ***
https://twitter.com/search?q= *** filter:follows
nick
October 10, 2023, 9:13am
10
This should be close:
// #popclip
// name: test
// lang: js
// requirements: [text, "!urls"]
// after: copy-selection
const query = encodeURIComponent(popclip.input.text);
if (popclip.modifiers.option) {
popclip.openUrl(`https://twitter.com/search?q=${query}`);
popclip.openUrl(`https://twitter.com/search?q=${query}%20filter:follows`);
} else {
popclip.openUrl(`https://twitter.com/search?q=${query}%20lang:zh-cn`);
}
1 Like
live
October 10, 2023, 10:31am
11
Wow, thank you! The interaction works fine. However, I encountered one issue during usage, and I’m not sure what the reasons are:
The ‘lang:zh-cn’ parameter needs to be placed in the search box, for example, this snippet:
# popclip
name: Twitter
Icon: iconify:bi:twitter
url: https://twitter.com/search?q=*** lang:zh-cn
1 Like
nick
October 10, 2023, 1:31pm
12
Ah — I see. I have edited the original post
live
October 10, 2023, 1:53pm
13
Thank you very much! It’s working mostly fine now, but there’s a minor issue. When searching in Chinese, the search results are correct, but the input box displays garbled characters. Is this an encoding error?
nick
October 10, 2023, 2:10pm
14
Try again – I edited again. I think I should have put a %20 instead of a space
live
October 10, 2023, 2:37pm
15
Perfect! It’s working perfectly now! Thank you for your patience and assistance! ::
1 Like
nick
Split this topic
April 25, 2024, 6:09am
18
2 posts were merged into an existing topic: Option modifier not working in extension