0

I have absolutely no experience in chrome extension developing, but for some punctual need, I have to modify an existing extension, in order to ask the user to enter a port of connection for a socket.

It is composed of a manifest json file and two content scripts, one of which is the jquery library. I think it should be very simple, but after some google research, I could not find the direct answer to my problem.

manifest.json

{
  "name": "MyExtension",
  "version": "1.0",
  "manifest_version": 2,
  "content_scripts": [
    {
      "matches": ["http://myurl.com/"],
      "css": ["style.css"],
      "js": ["jquery-1.7.2.min.js", "script.js"]
    }
  ]
}

script.js

(function() {
    var sock = null;

    function connect() {
        if (sock !== null) {
            return;
        }

        sock = new WebSocket('ws://localhost:1234/'));

        [...]

    }

    [...]

})();

Just to be clear, my goal is to replace the '1234' port for the socket with a customized port set by the user through a dialog window.

Thanks by advance for your help,

Romain Laroche

Maveric78f
  • 55
  • 6
  • I tried to apply this: http://stackoverflow.com/questions/10340481/popup-window-in-chrome-extension, but couldn't access the form entry from my content script. Then I tried multiple variants, but I had frankly no idea of what I was doing. – Maveric78f Apr 16 '13 at 09:41
  • You should use an options page: http://developer.chrome.com/extensions/options.html, and save your value using chrome storage: http://developer.chrome.com/extensions/storage.html, so you can retrieve it directly in your content script. – rsanchez Apr 16 '13 at 14:37
  • Actually, it does not solve my overall issue. I'd like to open several times the same url in different chrome windows and to communicate with them (through a content script) with as many sockets on as many ports. – Maveric78f Apr 17 '13 at 14:59

0 Answers0