Additional Mouse Gestures
-
Thanks for that!
-
- When hovering over links, implement gestures for copying either the URL or the link text.
β Quick Command
Open Link in current Tab
Parameter :
javascript:(function() { var lastHoveredElement = null; function copyLinkInfo() { if (!lastHoveredElement) return; var url = lastHoveredElement.href; var text = lastHoveredElement.innerText; if (!url && !text) return; var copyText = url || text; navigator.clipboard.writeText(copyText) .catch(function(error) { console.error('An error occurred while copying to the clipboard.', error); }); } document.addEventListener('mouseover', function(event) { var target = event.target; if (target.tagName === 'A') { lastHoveredElement = target; setTimeout(copyLinkInfo, 100); } }); })();
{"category":"CATEGORY_COMMAND_CHAIN","chain":[{"defaultValue":"https://vivaldi.com","key":"0b01337b-4c13-4197-90c8-179c5c91cfff","label":"Open Link in Current Tab","name":"COMMAND_OPEN_LINK_CURRENT","param":"javascript:(function() { var lastHoveredElement = null; function copyLinkInfo() { if (!lastHoveredElement) return; var url = lastHoveredElement.href; var text = lastHoveredElement.innerText; if (!url && !text) return; var copyText = url || text; navigator.clipboard.writeText(copyText) .catch(function(error) { console.error('An error occurred while copying to the clipboard.', error); }); } document.addEventListener('mouseover', function(event) { var target = event.target; if (target.tagName === 'A') { lastHoveredElement = target; setTimeout(copyLinkInfo, 100); } }); })();"}],"key":"clt6zooso009k3564yh9c5osp","label":"Copy URL on Hover","name":"COMMAND_clt6zooso009k3564yh9c5osp"}
Made in ChatGPT.
-
As long as it works Thank you so much!
However, there's a problem: when copying the URL under the cursor with a mouse gesture or keyboard shortcut, the parameter value replaces the tab URL in the address bar.
-
However, there's a problem: when copying the URL under the cursor with a mouse gesture or keyboard shortcut, the parameter value replaces the tab URL in the address bar.
OK. Fixed.
javascript:(function(){var lastHoveredElement=null;function copyLinkInfo(){if(!lastHoveredElement)return;var url=lastHoveredElement.href;var text=lastHoveredElement.innerText;if(!url&&!text)return;var copyText=url||text;navigator.clipboard.writeText(copyText).catch(function(error){console.error('An error occurred while copying to the clipboard.',error);});}document.addEventListener('mouseover',function(event){var target=event.target;if(target.tagName==='A'){lastHoveredElement=target;setTimeout(copyLinkInfo,100);}});})();if(history.replaceState){history.replaceState({},null,location.href);}
{"category":"CATEGORY_COMMAND_CHAIN","chain":[{"defaultValue":"https://vivaldi.com","key":"0b01337b-4c13-4197-90c8-179c5c91cfff","label":"Open Link in Current Tab","name":"COMMAND_OPEN_LINK_CURRENT","param":"javascript:(function(){var lastHoveredElement=null;function copyLinkInfo(){if(!lastHoveredElement)return;var url=lastHoveredElement.href;var text=lastHoveredElement.innerText;if(!url&&!text)return;var copyText=url||text;navigator.clipboard.writeText(copyText).catch(function(error){console.error('An error occurred while copying to the clipboard.',error);});}document.addEventListener('mouseover',function(event){var target=event.target;if(target.tagName==='A'){lastHoveredElement=target;setTimeout(copyLinkInfo,100);}});})();if(history.replaceState){history.replaceState({},null,location.href);}"}],"key":"clt6zooso009k3564yh9c5osp","label":"Copy URL on Hover","name":"COMMAND_clt6zooso009k3564yh9c5osp"}
-
LLonM moved this topic from Desktop Feature Requests on
-
Thank you!
-
@shifte Iβm new to all this, how do I add this code to a new gesture?
-
@Skorobagatko
1, Settings > Quick Commands > Plus button
2, Settings > Mouse > New gesture > Select "Copy URL on Hover"
-
@shifte said in Additional Mouse Gestures:
@Skorobagatko
1, Settings > Quick Commands > Plus button
2, Settings > Mouse > New gesture > Select "Copy URL on Hover"
Thank you, I created quick command with the javascript you provided and assigned it to a shortcut, but nothing happens when I'm triggering it.
-
@Skorobagatko You should post here β https://forum.vivaldi.net/post/500553. This topic is for mouse gestures, moreover itβs on the wrong forum board too. Please include the whole Javascript, so we can test it.
edit: just saw you are using @shifteβs bookmarklet. It should work of course.
-
LLonM moved this topic from Modifications on
-
@Skorobagatko
I wonder why.
Please go to official page. https://help.vivaldi.com/desktop/shortcuts/command-chains/