Handling connection loss with websockets

You have to add ping pong method Create a code in server when receive __ping__ send __pong__ back JavaScript code is give below function ping() { ws.send(‘__ping__’); tm = setTimeout(function () { /// —connection closed /// }, 5000); } function pong() { clearTimeout(tm); } websocket_conn.onopen = function () { setInterval(ping, 30000); } websocket_conn.onmessage = function … Read more

How can my Add-on SDK content script interact with a website page script?

There are a multitude of ways to interact with page scripts, the most common of which are covered in the official documentation, including all of the ways listed in the question. Please read “Interacting with page scripts”. However, it should be pointed out that interacting with page scripts in a secure fashion can be hard. … Read more

Firefox extension custom fonts

If you look into the console messages, this is what you should see: downloadable font: download not allowed (font-family: “FontAwesome” style:normal weight:normal stretch:normal src index:0): bad URI or cross-site access not allowed Unfortunately for you, web fonts are subject to the same-origin policy which can only be relaxed via CORS. This means that there is … Read more

TypeError: [API] is undefined in content script or Why can’t I do this in a content script?

Content scripts do not have access the API you are using You are attempting to do this from a content script. You need to be doing this from a background script. Content scripts have access to a small subset of the WebExtensions APIs. The available APIs include (from the MDN Content Scripts page): From extension: … Read more

How I can make a browser action button that looks and acts like a toggle

Your code While you added a switch statement to switch on button, you never defined button, nor changed its state. You also did not have a default case, just in case the button variable was not one of the values for which you were testing in your case statements. You should not be using browserAction.setPopup() … Read more

What is this JavaScript syntax: {Ci, CC}? [duplicate]

This is called destructuring assignment. It is a feature of JavaScript 1.7, where in this context “JavaScript” refers to Mozilla’s specific extensions to the ECMAScript standard. It is slated for inclusion in the next version of JavaScript. The equivalent ECMAScript 5 code would be var __temp = require(‘chrome’); var Cc = __temp.Cc; var Ci = … Read more