Skip to content

Instantly share code, notes, and snippets.

View freaktechnik's full-sized avatar
🚞
I like trains

Martin Giger freaktechnik

🚞
I like trains
View GitHub Profile
/**
* A Promise that centralizes initialization of ExtensionStorageSync.
*
* This centralizes the use of the Sqlite database, to which there is
* only one connection which is shared by all threads.
*
* Fields in the object returned by this Promise:
*
* - connection: a Sqlite connection. Meant for internal use only.
* - kinto: a KintoBase object, suitable for using in Firefox. All
/* vim: sw=2 ts=2 sts=2 expandtab filetype=javascript
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
var EXPORTED_SYMBOLS = [ "RelativeTimeUtils" ];
/**

Other extensions can query the assigned contextual identity of a given URL, if they have the contextualIdentities permission.

API

browser.runtime.sendMessageExternal('@testpilot-containers', {
  method: 'getAssignment',
  url: 'https://example.com'
}).then((assignment) => {
  // Use result
});
@freaktechnik
freaktechnik / auto-filter-table.js
Last active January 15, 2018 19:42
Table sorting and filtering scripts
// Copyright (c) 2018 Martin Giger
//
// MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
> justintv-stream-notifications@3.6.0 start /home/martin/dev/justintv-stream-notifications
> webpack && web-ext run -s webextension/ "-f" "nightly" "--verbose"
Hash: 975bc1585cd4fae6738d
Version: webpack 3.8.1
Time: 3323ms
Asset Size Chunks Chunk Names
popup/list/index.js 126 kB 0 [emitted] popup/list
vendor/lodash.min.js 72.8 kB [emitted]
@freaktechnik
freaktechnik / background.js
Created November 17, 2017 20:02
Tab counter via canvas
"use strict";
const ICON_SIZE = 64;
const getIcon = async (count, size = ICON_SIZE) => {
const canvas = document.createElement("canvas");
const ctx = canvas.getContext('2d');
const {
bgColor,
color
@freaktechnik
freaktechnik / CONTRIBUTING.md
Last active October 11, 2017 17:53
Preparation of the Content Queue CONTRIBUTING explanations for Mozilla.ch

@mozillaCH Content Queue

The concept

This repository serves as a curation tool for the @MozillaCH Twitter account. Each issue represents a Tweet or Retweet on that account. The issue gets validated by a service, if it is tweetable. If it is deemed ready and the curators of the Twitter account accept the content it will eventually be tweeted. This allows any user with a GitHub account to suggest content for the Twitter account while still retaining control over what is actually tweeted. Further it simplifies letting multiple users tweet from a single account.

How to submit a tweet

Open an issue

To suggest tweet content, open an issue in this repository and fill out the issue template. The issue will be added to the "Ideas" column on our project board.

Tweets should be English, though linked content does not need to be English. You can attach images by uploading them to the issue and embedding them using the GitHub image syntax in the tweet content.

const STRINGS = {
"elementid": "stringid"
}
for(let i in STRINGS) {
document.getElementById(i).textContent = browser.i18n.getMessage(STRINGS[i]);
}
const PREFS = {
"translate_now_destination_language": {
"type": "value",
"default": "en"
},
"translate_now_source_language": {
"type": "value",
"default": "auto"
},
"translate_now_reuse_tab": {
@freaktechnik
freaktechnik / data-store.js
Last active April 26, 2024 22:09
A proxy based magic data caching store.
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
/**
* Returns API data to store.
*