Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8476111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:05:22+00:00 2026-06-10T18:05:22+00:00

Making safari extension imageSearch By google. Here is my source. injected.js document.addEventListener(contextmenu, handleContextMenu, false);

  • 0

Making safari extension imageSearch By google.

Here is my source.

injected.js

document.addEventListener("contextmenu", handleContextMenu, false);

function handleContextMenu(event) {
    safari.self.tab.setContextMenuEventUserInfo(event, event.target.nodeName);
}

global.html

<!DOCTYPE HTML>
<script type="text/javascript" src="jquery.js"></script>
<script>
safari.application.addEventListener("contextmenu", handleContextMenu, false);
function handleContextMenu(event) {
    var query = event.userInfo;
    if (query === "IMG") {
        event.contextMenu.appendContextMenuItem("imageSearch", "Search Google with this image");
    }
}

safari.application.addEventListener("command", performCommand, false);
function performCommand(event) {
    if (event.command === "imageSearch") {  


       /*How I get image Url??? */
       var imageUrl="";


    /*
        var url = "http://images.google.com/searchbyimage?image_url="+imageUrl;
        var tab = safari.application.activeBrowserWindow.openTab("foreground");
        tab.url = url;

    */

    }
}

My goal is..

  1. if mouse rightclick add “Search by Google With This Image” int the context menu. (clear)

  2. and click “Search by Google With This Image” google it. (???)

so i want to know image url.

What should I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T18:05:24+00:00Added an answer on June 10, 2026 at 6:05 pm

    You could try this:

    1. store the whole node into the event’s userInfo:

      function handleContextMenu(event) {
          safari.self.tab.setContextMenuEventUserInfo(event, event.target);
      }
      
    2. add some global javascript variable to your global.html (e.g. var lastClickedImg),

    3. change your handleContextMenu function to store the event.userInfo in function handleContextMenu to this variable:

      function handleContextMenu(event) {
          var query = event.userInfo;
          if (query.nodeName === "IMG") {
              lastClickedImg = query;
              event.contextMenu.appendContextMenuItem("imageSearch", "Search Google with this image");
          }
      }
      
    4. in your function performCommand you will easily get the image’s url from lastClickedImg:

      lastClickedImg.src
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making an application that involves controlling Safari from Applescript. Is there a
Making a word document of our network set-up. We have about 7 servers and
I am making this web site http://www.christopherbier.com/gbg/locations.html In safari on mac the content div
I'm making table rows click-able with jQuery's $.live() function. Works perfectly on Chrome, Firefox
im using some js to insert safari specific styles on a website im making.
I'm making a site that works flawless in Chrome and Firefox. But in Safari
I am making a game using html canvas. Here is my progress: http://db.tt/ei3LlR (use
I am making a web application using google app engine. I was not using
i'm making an ajax call to a php function... i'm trying to display the
I am making something like a landing page. The page looks okay in Safari,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.