Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New to the CF scene
    Join Date
    Jun 2017
    Thanked 0 Times in 0 Posts

    How do I insert chrome API javascript code into persistent inject/background js file

    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": "Dark Reader"
    "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:

    var c=chrome.contextMenus;
    "title": "Search Image with Tineye",
    "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), certainly if Tineye codes above is inserted to SAMPLE above neither will work.

    Help me sincerely please !?
    Thanks in advance for sincere help
    Last edited by vinyl-junkie; Jun 5th, 2018 at 09:07 AM. Reason: added code tags


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts