diff --git a/chrome-extension/background.js b/chrome-extension/background.js index 469d7dc..8dd5d08 100644 --- a/chrome-extension/background.js +++ b/chrome-extension/background.js @@ -21,7 +21,7 @@ function getClickHandler() { // strip the google images redirect if ( s.startsWith("https://www.google.com/url?") ){ let parts = s.split("?"); - alert("parts length= " + parts.length); + if ( parts.length == 2 ){ let params = parts[1].split("&"); @@ -29,8 +29,6 @@ function getClickHandler() { for( let i = 0; i < params.length; ++i ){ let kv = params[i].split("="); - alert(JSON.stringify(kv)); - if ( kv.length == 2 ){ if ( kv[0] == "url" ){ s = decodeURIComponent(kv[1]); @@ -50,12 +48,24 @@ function getClickHandler() { var q = "i=" + encodeURIComponent(info.srcUrl) + "&s=" + s; - // The srcUrl property is only available for image elements. - var url = 'http://localhost:3000/addpin.html#' + q; - - // Create a new window to the info page. - // chrome.windows.create({ url: url, width: 520, height: 660 }); - chrome.windows.create({ url: url, width: w, height: h, left: left, top: top, type: 'popup' }); + + chrome.storage.sync.get({ + server: 'http://localhost:3000' + }, function(items){ + let server = items.server; + + if ( !server.endsWith('/') ){ + server += '/'; + } + + var url = server + 'addpin.html#' + q; + + // Create a new window to the info page. + // chrome.windows.create({ url: url, width: 520, height: 660 }); + chrome.windows.create({ url: url, width: w, height: h, left: left, top: top, type: 'popup' }); + }); + + }; }; diff --git a/chrome-extension/manifest.json b/chrome-extension/manifest.json index 727bfcc..9e428a2 100644 --- a/chrome-extension/manifest.json +++ b/chrome-extension/manifest.json @@ -4,8 +4,13 @@ "description": "add to tinypin context menu plugin", "manifest_version": 2, "background" : { "scripts": ["background.js"] }, + "options_ui" : { + "page": "options.html", + "open_in_tab": false + }, "permissions" : [ - "contextMenus" + "contextMenus", + "storage" ], "icons": { "16" : "icon16.png", diff --git a/chrome-extension/options.html b/chrome-extension/options.html new file mode 100644 index 0000000..e0db796 --- /dev/null +++ b/chrome-extension/options.html @@ -0,0 +1,22 @@ + + +
+