Skip to content

Instantly share code, notes, and snippets.

@myrdd
myrdd / sinon-chrome.js
Created April 7, 2018 05:20
extend sinon-chrome
// source: https://github.com/RequestPolicyContinued/requestpolicy/blob/1c9810d005a0bc12a7719484bf63f58616ff6cbf/tests/mocha/lib/sinon-chrome.js
const stableApiFx = require("sinon-chrome/config/stable-api-ff.json");
const Api = require("sinon-chrome/api");
for (let ns of stableApiFx) {
if (ns.namespace === "management") {
if (!("events" in ns)) ns.events = [];
ns.events.push({
"name": "onEnabled",
@myrdd
myrdd / map-builder.ts
Created December 21, 2017 17:09
MapBuilder
interface IMapValueFactory<K, T> {
construct: (key: K) => T;
}
interface IMapBuilder<K, T> {
maybeConstruct: (key: K) => void;
get: (
((key: K, maybeConstruct?: boolean) => T | undefined) &
((key: K, maybeConstruct: true) => T)
);
@myrdd
myrdd / convert.py
Created December 12, 2017 07:41
convert RequestPolicy's `*.properties` I18n files of the legacy xpcom-based firefox extension to WebExtension-type `message.json` files
#!/usr/bin/python3
# source: https://github.com/RequestPolicyContinued/requestpolicy/issues/876
import os
import re
default_locale = 'en-US'
locales = [
'de', 'en-US', 'eo', 'es-ES', 'es-MX', 'eu', 'fr', 'it', 'ja', 'ko-KR',
@myrdd
myrdd / UserChrome.css
Created November 15, 2017 14:32
RequestPolicy "color theme" (UserChrome.css) template
#rpc-contents {
background-color: #ffffff;
}
#rpc-origins-destinations [selected-origin="true"] {
border-color: #ddd !important;
background-color: #eaeaea;
}
#rpc-origins-destinations [selected-origin="false"]:hover {
border-color: #eee !important;
@myrdd
myrdd / rpbug.css
Created October 4, 2017 08:37
RequestPolicy issue #847 – Greasemonkey
body {
border: dashed 2px magenta;
}
/**
* This function will be called before an add-on wraps
* a `gBrowser` function. A reference to the original
* function will be saved in `gBrowser.originalFunctions`.
*/
function beforeWrap(gBrowser, fnName) {
// Ensure that `gBrowser.originalFunctions` exists.
if (!gBrowser.hasOwnProperty("originalFunctions")) {
gBrowser.originalFunctions = {};
}
@myrdd
myrdd / GCC-preprocess-JavaScript
Last active August 29, 2015 14:25
using GCC's preprocessor for JavaScript
usage: see the bash script