0

manifest.json

{
    "name": "Omegle IP",
    "version": "0.5",
    "options_page": "options.html",
    "options_ui": {
    "page": "options.html",
    "open_in_tab": false
    },
    "background": {
    "scripts": ["background.js"],
    "persistent": true
    },
    "manifest_version": 2,
    "description": "Become a Hacker; You see the IP in the chat window",
    "permissions": ["tabs", "https://*.omegle.com/*", "storage"],
    "web_accessible_resources": ["inject.js"],
    "content_scripts" : [{
        "matches" : ["https://*.omegle.com/*"],
        "run_at": "document_end",
        "js" : ["contentscript.js"]
    }],
    "icons": {
        "16": "16.png",
        "32": "32.png",
        "48": "48.png",
        "128": "128.png"
    }
}

contentscript.js

var s = document.createElement('script');
// TODO: add "script.js" to web_accessible_resources in manifest.json
s.src = chrome.runtime.getURL('inject.js');
s.onload = function() {
    this.remove();
};
(document.head || document.documentElement).appendChild(s);

inject.js

chrome.storage.sync.get(['tracker', 'api'], function (obj) {
        tracker = obj.tracker;
        api = obj.api;
        getIp(tracker, api);
    });

function getIp(tracker, api){
    console.log(tracker + api)
}

I cant access chrome.storage.sync.get from inject.js. But I need to... Is there a way to put the chrome request to the contentscript and pass the variables to inject.js contentscript.js basically just creates a script field and puts the inject.js into it. the inject.js file is normally larger, but you dont need all of that There is a post "https://stackoverflow.com/questions/9515704/use-a-content-script-to-access-the-page-context-variables-and-functions" how to implement this, i tried but i didnt achieve to get it to work... Could you please provide a working method, to get it to work?

  • Quoting the linked topic: since chrome.* APIs can't be used in the exposed page script directly, you have to use them in the content script and communicate to the exposed page script via a special DOM CustomEvent handler. – wOxxOm Nov 07 '20 at 06:57
  • @wOxxOm okay that might be answered, but how to do it.. i dont understand. i asked the question to get a individual answer... – kaaaxcreators Nov 08 '20 at 00:46
  • Call chrome.* stuff in contentscript.js and send the result using CustomEvent as shown in the linked topic, [here's an example](https://stackoverflow.com/a/19312198). – wOxxOm Nov 08 '20 at 04:12

0 Answers0