Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var context = {
- init: function () {
- this.add({
- title: localStorage["isEnabled"] == null ? "Disabled" : ((localStorage["isEnabled"] == "1") ? "Disabled" : "Enabled"),
- urlPatterns: ["http://*.facebook.com/*", "http://facebook.com/*", "https://*.facebook.com/*", "https://facebook.com/*", "http://*.flickr.com/*", "http://flickr.com/*", "https://*.flickr.com/*", "https://flickr.com/*"],
- checked: localStorage["isEnabled"] == null ? true : ((localStorage["isEnabled"] == "1") ? true : false)
- }, "setEnabled");
- this.add({
- title: "Search Images for %s",
- contexts: ["selection"]
- }, "SrchImgByTxt");
- this.add({
- title: "Search for similar Images",
- contexts: ["image"]
- }, "SrchImg");
- },
- add: function (params, event) {
- var contextInfo = {
- type: params.type || "normal",
- title: params.title || "",
- documentUrlPatterns: params.urlPatterns || ["http://*/*", "https://*/*"],
- contexts: params.contexts || ["all"]
- }
- if (params.type == "checkbox") {
- contextInfo.checked = typeof (params.checked) == "boolean" ? params.checked : false;
- }
- contextInfo.onclick = this.contextClicks[event];
- if (this.contextItems[event]) {
- chrome.contextMenus.update(this.contextItems[event], contextInfo, function () { });
- } else {
- this.contextItems[event] = chrome.contextMenus.create(contextInfo, function () { });
- }
- },
- contextItems: {},
- contextClicks: {
- setEnabled: function () {
- var isEnabled;
- var ttlText;
- if (localStorage["isEnabled"] == "1") {
- localStorage["isEnabled"] = "0";
- isEnabled = false;
- ttlText = "Enabled";
- _gaq.push(["_trackEvent", "UserInfo", "Functionality", "Disabled | " + localStorage["install"] + " | Chrome"]);
- } else {
- localStorage["isEnabled"] = "1";
- isEnabled = true;
- ttlText = "Disabled";
- _gaq.push(["_trackEvent", "UserInfo", "Functionality", "Enabled | " + localStorage["install"] + " | Chrome"]);
- }
- if (context.contextItems["setEnabled"]) {
- chrome.contextMenus.update(context.contextItems["setEnabled"], { title: ttlText }, function () { });
- }
- chrome.tabs.getSelected(null, function (tab) {
- chrome.tabs.sendRequest(tab.id, { 'name': 'setStatus', 'data': isEnabled });
- });
- },
- SrchImgByTxt: function (info) {
- var url = "http://www.gophoto.it/result.php?type=1&src=fbz&q=" + info.selectionText;
- chrome.tabs.create({ 'url': url }, function (tab) { });
- },
- SrchImg: function (info) {
- var url = "http://www.gophoto.it/result.php?type=2&src=fbz&q=" + escape(info.srcUrl);
- chrome.tabs.create({ 'url': url }, function (tab) { });
- }
- }
- };
- try { context.init(); } catch(e) {};
Advertisement
Add Comment
Please, Sign In to add comment