0

I'm trying to create a chrome extension that will allow a user to right click a file and choose to send it to an online service that will then do something (haven't made it that far yet) to it. However I'm having trouble getting it to work. I'm very new to jquery so this is probably a simple fix.

function uploadfile(info)
{
    var fileurl = info.srcUrl;

    var file;
    $.get(fileurl, function(data) {
            file = data;
            alert(fileurl);
    });
}

chrome.contextMenus.create({title: "send somewhere", contexts:["image"], onclick: uploadfile});
alert();

The alerts are just my way of trying to debug (very open to better ways). Also my manifest:

{
   "name": "Practice",
   "version": "0.1",
   "manifest_version": 2,
   "description": "Practice",
   "icons": {
      "16": "icon1.png",
      "48": "icon2.png"
   },
   "background": {
      "scripts": ["background.js"]
    },
   "permissions": [ "contextMenus",
      "tabs",
      "https://*/*",
      "http://*/*"
      ],
   "content_scripts": [ 
    {
      "matches": ["http://*/*"],
      "js": ["jquery.js"]
} ]


}
  • re: alerts: you can use `console.log` – akonsu Oct 17 '13 at 18:56
  • you need to list `jquery.js` in your background scripts array, before `background.js`. Also see http://stackoverflow.com/questions/10257301/where-to-read-console-messages-from-background-js-in-a-chrome-extension for using the chrome debugging tools with a background script. – rsanchez Oct 17 '13 at 19:04
  • Well that fixed all of that. Thanks rsanchez. – OverworkedTechydude Oct 17 '13 at 19:13

0 Answers0