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

Install WebExtensions on Firefox from the command line

Please see: Installing extensions Customizing Firefox: Including extensions with your distribution of Firefox The question you link on askubuntu: How to install Firefox addon from command line in scripts? is several years out of date, but does have some good information. At this point, most Mozilla add-ons, including all Firefox WebExtension add-ons, are installed manually … 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

How to download image to desktop with OS.File

You stole half that from my solution here: https://stackoverflow.com/a/25112976/3791822 And the other half from @nmaier’s solution here: https://stackoverflow.com/a/25148685/3791822 Very nice 😉 Haha anyways you are real close. You got the ArrayBuffer but pass it as Uint8Array so: var promised = OS.File.writeAtomic(file, new Uint8Array(data)); I don’t know if this is the best way to download it. … Read more

.setAttribute(“disabled”, false); changes editable attribute to false

A disabled element is, (self-explaining) disabled and thereby logically not editable, so: set the disabled attribute […] changes the editable attribute too Is an intended and well-defined behaviour. The real problem here seems to be you’re trying to set disabled to false via setAttribute() which doesn’t do what you’re expecting. an element is disabled if … 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

Convert URL to File or Blob for FileReader.readAsDataURL

To convert a URL to a Blob for FileReader.readAsDataURL() do this: var request = new XMLHttpRequest(); request.open(‘GET’, MY_URL, true); request.responseType=”blob”; request.onload = function() { var reader = new FileReader(); reader.readAsDataURL(request.response); reader.onload = function(e){ console.log(‘DataURL:’, e.target.result); }; }; request.send();

Inspecting WebSocket frames in an undetectable way

Intercepting the WebSocket data is easy. Simply execute the following script before the page constructs the WebSocket. This snippet monkey-patches the WebSocket constructor: When a new WebSocket constructor is created, the snippet subscribes to the message event, from where you can do whatever you want with the data. This snippet is designed to be indistinguishable … Read more