Skip to content

Instantly share code, notes, and snippets.

@freaktechnik
freaktechnik / elementary-apps.md
Last active April 26, 2024 22:11
Nice elementary packages I like to add
"use strict";
// Require some stuff
const { myMethod } = require("my-method");
// Init code
myMethod("initializing");
...
// Cleaning up
const run = async (allowRefresh) => {
const response = await this.runRequest(methid, url, data);
if(this.requireRefresh(response) && allowRefresh)
return 'refresh';
else if(response.error)
throw response;
else
return response;
};
const panel = new Panel({...});
const runLoop = (text, i = 0) => {
// do something
self.port.once("updated-something", runLoop.bind(null, text, i + 1));
self.port.emit("update-something", data);
};
panel.port.on("text-changed", (text) => {
runLoop(text);
@donpandix
donpandix / valida_rut.js
Last active April 26, 2024 22:11
Valida RUT chileno con JavaScript
var Fn = {
// Valida el rut con su cadena completa "XXXXXXXX-X"
validaRut : function (rutCompleto) {
if (!/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test( rutCompleto ))
return false;
var tmp = rutCompleto.split('-');
var digv = tmp[1];
var rut = tmp[0];
if ( digv == 'K' ) digv = 'k' ;
return (Fn.dv(rut) == digv );
<select id="resolution">
<option value="1080p60" label="1080p 60FPS">
<option value="720p" label ="720p 30FPS">
<option value="mp3" label="Audio only (mp3)">
</select>
<script src="index.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf8">
</head>
<body>
<script src="https://player.twitch.tv/js/embed/v1.js"></script>
<div id="player"></div>
<script type="text/javascript">
var options = {
@freaktechnik
freaktechnik / l10n.js
Last active April 26, 2024 22:10
Drop-in script to localize HTML sites in WebExtensions like it was the Add-on SDK.
/**
* Translates a HTMl page in the web l10n style from the Add-on SDK with
* WebExtensions strings.
* Large parts of the logic are very similar to the SDK implmentation.
* All you have to do to use this in a document is load it.
*
* It supports some additional attributes:
* - The "translate" attribute is fully respected (see
* https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/translate)
* - "data-l10n-nocontent" means that the text content of the element
new Promise((resolve, reject) => {
passwords.search({
onError: reject,
onComplete: resolve
});
}).then((asdf) => {
foo();
}, (err) => {
console.error('passwords failed');
console.error(err);

On addons.mozilla.org Reviews

Files generated by webpack and friends are compiled files. You have to upload the source you generated your extension from to AMO for review of a listed extension. This will mean that your extension has to be reviewed by an admin-reviewer, which will result in a longer wait time in queue.

If you are ok with that trade-off there are a few measures you can take to make the review easier:

  • Don't minify the generated code (UglifyJsPlugin for webpack)
  • Don't use loaders that transform the JS output (like babel or similar)
  • Don't include third-party libraries in your file, instead directly use the original source file