Command Chain Recipes
-
@luetage, I added a new chain to my previous post. My old "New Stacked Tab" chain required changing a setting that adversely affected "New Top Level Tab" behavior, and my new command "New Top Level Tab at End" functionally restores the desired behavior using new v5.1 commands.
-
Thought I'd cross-post this here (from the Copy from adress bar in a formated way (like on MS Edge) feature request thread):
Copy the current page's URL & title as a rich text
(eg. copy Home | Vivaldi Forum instead of
https://forum.vivaldi.net
)Command 1:
Open Link in Current Tab
Command Parameter:javascript:function copy(c){c.clipboardData.setData('text/html','<a href="'+location.href+'">'+document.title+'</a>');c.preventDefault();}document.addEventListener("copy",copy);document.execCommand("copy");document.removeEventListener("copy",copy);history.replaceState({},"",location.href);
-
Welp, the latest snapshot just broke this chain, although this gives me hope
Now working again as intended
Save Tab Stack as session:
Command 1: Deselect Tabs
Command 2: Select Current Tab
Command 3: Save Selected Tabs as SessionHow I use the chain
I set this chain to Ctrl+S, save all to Ctrl+Shift+S, and open saved session to Ctrl+O.
When I have a project I want to close and come back to, all I need to do is Ctrl+S, Space [or a descriptive name I guess ], Enter, Ctrl+W.
-
@legobuilder26 @ukanuk @pafflick Nice ideas, added all of them to OP now.
@pafflick I added your chain, but it doesn’t work for me, it makes no new entry in clipboard. Hard to tell why, looks ok to me. But I’d assume people could run into issues in certain circumstances. Beats me. Other chains that copy to clipboard work fine.
-
-
@pafflick This works.
-
@luetage any errors in the console? Does it work when you execute it through the console?
-
@pafflick
No, nothing in the console.edit: figured it out, the copied text just doesn’t show up in the clipboard history program but is still being copied.
-
I see many recipes that work on either current URL or selected text - I'm wondering if it's possible to use the context menu for images, to work on the URL of the image? Does anyone know if that's possible, or do I have to open the image in a new tab first and then work on the tab URL?
-
@tuexss There is no command to open image in new tab as part of a command chain. And if there was one, you would need to select the image first. You also can’t work on the image URL in the context menu. What is it you try to achieve exactly? You could always write a bookmarklet as part of the command chain to get the URL of the image and either process it directly or open in a new tab to work from there. But yeah, no idea what you’re trying to do.
-
@luetage I'm trying to search for an image in three reverse image search engines in parallel. Currently I have an item in the context menu "Search for image" in google search, but other search engines I have to open manually, and it's an annoying mindless task. So I thought command chains would be perfect for that.
-
@tuexss And the engines search when you feed them the image url? That should be doable. E.g.:
- hover image
- trigger command chain
- first command is a bookmark which triggers javascript code to get the image url for the image under the cursor
- copy the url
- paste url either in address field or by creating a temporary fake input field
- select the url
- then three commands to search with selection, the image reverse engines have to be part of your search engine list
The only tricky thing is writing the bookmarklet, but it’s not too bad.
-
@luetage ah ok, so bookmarklets are the trick to get this. didn't think of that, nice.
-
@tuexss Well, tell me whether you need help with this down the line.
-
@luetage hmm, it always opens "chrome-extension://mpognobbkildjkofajifpdfhcoklimli/" which seems to be the url of the context menu, and not of the image or the webpage I'm on.
so here's what I done so far:
- created a new command chain
- added a trigger for the command chain to the image context menu
- cobbled this together to start testing with one search provider:
javascript:$("img").mouseover(function(e){window.open("https://www.google.com/searchbyimage?&image_url="+$('<a/>').attr('href',e.target.src)[0].href);});
- created a bookmark for this script
I'm a bit confused about whether mouseover is the right way to retrieve, or if I have some context based on the origin of the trigger.
Also I'm confused which action to select in the command chain: Open Link in New Tab? I can't open a bookmark it seems. Tried adding the javascript as a paramter to Open Link, but then it opens the chrome-extension URL with the javascript attached to it.
-
@tuexss You have to »open link in current tab« for the bookmarklet to run on the current page. And mouseover is the right approach in my opinion, but you might have to create a loop to search the image source in the parent/child nodes. The bookmarklet itself shouldn’t open the tab, or you won’t be able to search 3 different engines at the same time.
-
@luetage ok, that works fine with current tab. but
.mouseover
triggers on any img that I move mouse over after activating the context menu item..click
requires another click on the image. I'm wondering what the DOM state is at the time when I open the context menu and if I can use that to identify the img. Because otherwise I could just go with a bookmarklet to do the whole job. -
@tuexss I wouldn’t do it with a context menu, because when the chain triggers you won’t be over the image, but over the menu. Trigger it from quick commands, or create a dedicated keyboard shortcut.
And yes, you have to stop execution of the function after finding the source. I’ll take a look at this later, this shouldn’t be too hard.
-
@luetage I see why key command makes more sense, but I have no luck triggering the command chain via key commands, nothing happens.
-
@tuexss Try this:
Reverse Image Search
- Open Link in Current Tab
Parameter:javascript:(()=>{function i(e){if(e.target.tagName==="IMG"){document.removeEventListener("mousemove",i);let u=e.target.getAttribute("src");if(u){const a=document.createElement("a");if(u.startsWith("..")){u=window.location.origin+u.slice(2)}a.innerText=u;console.info(`reverse image search ${ u }`);a.style.opacity="0";a.style.fontSize="0em";document.body.appendChild(a);const r=document.createRange();r.selectNodeContents(a);window.getSelection().addRange(r)}}}window.getSelection().removeAllRanges();document.addEventListener("mousemove",i);setTimeout(()=>document.removeEventListener("mousemove",i),1900);history.replaceState({},"",location.href)})();
- Delay
Parameter:2000
- Search Selection with Engine
Parameter:select engine
- Delay
Parameter:500
- Previous Tab (Recent)
- Search Selection with Engine
Parameter:select engine
- Delay
Parameter:500
- Previous Tab (Recent)
- Search Selection with Engine
Parameter:select engine
The javascript listens for mouse movement. This means you can use this from context menu, if you want (shortcut or qc might still be more comfortable). During a span of 2 seconds you will have to move the mouse inside or over an image tag, which has to contain a
src
attribute with a link to the image. Should this be successful, your image will be searched in the engines of your choice. In case no src is found the javascript aborts, but the command chain will still continue, so there might be some jumping around because of the »previous tab« commands. - Open Link in Current Tab