Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Open Image in New Tab #368

Open
christopher-wilson opened this issue Apr 24, 2022 · 1 comment
Open

Feature Request: Open Image in New Tab #368

christopher-wilson opened this issue Apr 24, 2022 · 1 comment

Comments

@christopher-wilson
Copy link

Currently we can view an image, but it would be helpful to go one step further and let us open an image in a new tab.

This is extremely useful in cases where there is an embedded image bound to a link and we don't want to open the link, just the image.

@christopher-wilson christopher-wilson changed the title Open Image in New Tab Feature Request: Open Image in New Tab Apr 24, 2022
@morat523035
Copy link

morat523035 commented May 2, 2022

You can do that with a user script.

Open Image In New Tab
http://github.com/marklieberman/foxygestures/wiki/User-Scripts#examples

Here is how to open an image or a background image in a new tab.

/* Foxy Gestures UserScript */

(function () {

  var src = data.element.mediaSource;
  if (!src) {
    var elem = mouseDown.target;
    if (elem) {
      var prop = getComputedStyle(elem).getPropertyValue("background-image");
      src = prop.slice(4, -1).replace(/"/g, "");
    }
  }
  if (src) {
    executeInBackground(aSrc => {
      browser.tabs.create({
        url: aSrc,
        active: false,
      });
    }, [src]);
  }

}());

Test page
http://forums.mozillazine.org/viewtopic.php?f=39&t=3088564

The top right blimp on the test page is a background image.

Blimp image
http://forums.mozillazine.org/static/common/images/blimp.png

You can view all images by type in the Page Info Media tab.

i.e. Menu Bar > Tools > Page Info > Media

WebExtensions API tabs
http://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/tabs
http://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/tabs/create

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants