0 Replies - 581 Views - Last Post: 05 June 2018 - 12:10 AM

#1 BudiKusasi   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 04-June 17

insert chrome API javascript code into persistent inject and/

Posted 05 June 2018 - 12:10 AM

How do I insert chrome API javascript code into persistent inject and/or background js file of Chrome browser plugin which has manifest file:

{
"background": {
"page": "background/index.html",
"persistent": true
},
"browser_action": {
"default_icon": {
"19": "icons/dr_active_19.png",
},
"default_popup": "ui/popup/index.html",
"default_title": "SAMPLE"
},
"commands": {
"addSite": {
"description": "__MSG_toggle_current_site__",
"suggested_key": {
"default": "Alt+Shift+A"
}
},
"switchEngine": {
"description": "__MSG_theme_generation_mode__"
},
"toggle": {
"description": "__MSG_toggle_extension__",
"suggested_key": {
"default": "Alt+Shift+D"
}
}
},
"content_scripts": [ {
"all_frames": true,
"js": [ "inject/index.js" ],
"matches": [ "\u003Call_urls>" ],
"run_at": "document_start"
} ],
"default_locale": "en",
"description": "__MSG_extension_description__",
"icons": {
"16": "icons/dr_16.png",
},
"manifest_version": 2,
"name": "SAMPLE",
"permissions": [ "fontSettings", "storage", "tabs", "\u003Call_urls>", "contextMenus" ],
"version": "1.0.0"
}


the codes need to be inserted is:

chrome.contextMenus.create({
"title": "Search Image with Tineye",
"contexts":["image"],
"onclick": function(info, tab) { //The callback func. Any parameter with its properties is retrieved as onclick fires
chrome.tabs.create({url: 'https://tineye.com/search/?pluginver=chrome-1.1.5&sort=score&order=desc&url=' + encodeURIComponent(info.srcUrl), active: false});
}
});


Each run perfect in its separate plugin package (the full detail not shown for simplicity) but certainly if Tineye codes above is merged/inserted to 'SAMPLE' plugin above neither will work.

Help me sincerely please !?
Thanks in advance for sincere help

Is This A Good Question/Topic? 0
  • +

Page 1 of 1