Customize image context menu?
-
I would like to write a bit of Javascript that I can then invoke by right-clicking on any image that appears on a web page. The Javascript will take the image's URL, do some manipulation on it, and then open the new URL in a new tab.
I think I can do the Javascript myself, but I'm unsure on how to add a new context menu item so it appears when I right-click the image. I'm not even sure if it's possible to get Vivaldi to run your own Javascript functions.
Any help or pointers for where I can look? I'm running Vivaldi 3.6.2165.36 on Linux Mint.
Thanks guys!
-
@TheBitBandit I'm sure you'll get help here very soon, as I got today already.
For now, you can browse here. -
@TheBitBandit Your best bet would be to make a simple extension. You could also make a JavaScript mod, but then you would need to re-add the mod after each Vivaldi update.
The extension API you would be interested in is Chrome.contextMenus.
You would use a
contextType
ofimage
to get it to only show up on images. And you would just add the logic you want to run to theonClick
attribute in the creation.Let me know if you need help making the extension. I think I already have a minimal context menu extension on my computer from when I wanted to test adding a bookmark folder to the context menu.
-
@nomadic said in Customize image context menu?:
I think I already have a minimal context menu extension on my computer from when I wanted to test adding a bookmark folder to the context menu.
...or from 'goto parent tab' :face_with_stuck-out_tongue_winking_eye:
-
@nomadic Definitely an extension, it’s far easier ☛ https://developer.chrome.com/docs/extensions/reference/contextMenus/
edit: and it’s safe to ignore the “deprecated” part I think, has to be a mistake.
-
@potmeklecbohdan haha, forgot I made that.
Since that is already on GitHub, maybe you can use it as a reference @TheBitBandit.
There is obviously some stuff you don't need, but should help get you started.
https://github.com/ortiza5/go-to-parent-tab
@luetage said in Customize image context menu?:
edit: and it’s safe to ignore the “deprecated” part I think, has to be a mistake.
Yeah, I looked into that too. Apparently it is just a bug in the documentation involving the depreciation of Chrome Apps, but Google hasn't bothered to fix it so it doesn't show the warning for extensions.
-
@nomadic said in Customize image context menu?:
@TheBitBandit Your best bet would be to make a simple extension.
Thanks @nomadic, that should be enough info to get me started.
I'm also playing around with Tampermonkey which I've used in the past and it might be able to do what I want too, but in a slightly less elegant way.
-
@TheBitBandit You don’t need tampermonkey, userscripts install directly in Vivaldi.
-
@luetage said in Customize image context menu?:
@TheBitBandit You don’t need tampermonkey, userscripts install directly in Vivaldi.
They do? Can you point me to any documentation on how they work in Vivaldi (eg where to put the scripts, etc) because my Googlefoo is failing me?
-
@TheBitBandit See this folder:
\Vivaldi\Application\3.6.2165.32\resources\vivaldi\user_files
The user style sheets are used by Page Actions. You can add your own CSS and JS files to this folder.
-
Thanks @Pesala I'll give that a try and do some experimenting. Will my user scripts carry over with each browser upgrade?
-
@TheBitBandit said in Customize image context menu?:
Will my user scripts carry over with each browser upgrade?
No. The application folder is replaced. Backup your user scripts and extract them after upgrading. I keep a Z-Zip archive of all of my custom files in the Vivaldi root folder, and back it up to Dropbox, and USB sticks.
-
@TheBitBandit Enable developer mode in
vivaldi://extensions
and just drag yourscript.user.js
file unto the extensions page. Will install just like an extension. -
@luetage said in Customize image context menu?:
@TheBitBandit Enable developer mode in
vivaldi://extensions
and just drag yourscript.user.js
file unto the extensions page. Will install just like an extension.That's great info, thanks @luetage!
-