Skip to content

Instantly share code, notes, and snippets.

var uas = () => {
// Once could just iterate through the ASCII code but finding the characters in builtin Objects is more fun!
var emptyString = new String();
var l = (new String(null)).split(emptyString).pop();
var earr = (new String(undefined)).split(emptyString);
var d = earr.pop();
var e = earr.pop();
var oarr = (new String(Object())).split(emptyString);
@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.
*
const PREFS = {
"translate_now_destination_language": {
"type": "value",
"default": "en"
},
"translate_now_source_language": {
"type": "value",
"default": "auto"
},
"translate_now_reuse_tab": {
const STRINGS = {
"elementid": "stringid"
}
for(let i in STRINGS) {
document.getElementById(i).textContent = browser.i18n.getMessage(STRINGS[i]);
}
@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

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
});
/* 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/. */
this.EXPORTED_SYMBOLS = [ 'ConversationStatusUtils' ];
const {Services} = ChromeUtils.import("resource:///modules/imServices.jsm");
const CHAT_TAB_HIDDEN_TOPIC = "chat-tab-hidden";
const CHAT_TAB_SHOWN_TOPIC = "chat-tab-shown";
  1. HTML/DOM tree structure (nodes, elements, parent/child)
  2. Roots and the document root
  3. Anatomy of a document
  4. CSS selectors and specifity
  5. Cascade order
  6. Block model -> blocks don't belong into inlines and how the block model layout works (block direction, inline direction)
  7. Other display models and how there's an inner and outer display mode
  8. Overlaps (earlier HTML draws on top of later html, child is above parent)
  9. non-static positioning
  10. Semantics
class PollEndpoint {
constructor(aOpts = {}) {
this.poll = aOpts.poll;
this.state = Object.assign({
isVisible: false, // timeline visibility (as in, are individual tweets visible)
isFocused: false, // IM tab focus
rateLimit: Infinity,
remaining: Infinity,
resetTime: Infinity,
requestsPerPoll: 1,
render() {
if(this.props.clip) {
return (<Clip .../>);
}
else {
return (<Loader/>);
}
}