Skip to content

Instantly share code, notes, and snippets.

@brettz9
brettz9 / redirect.html
Created March 4, 2014 12:27
Google Redirect bookmarklet and keyword target per http://brett-zamir.me/wiki/Google-Redirect
<script>
var url = window.location.href.match(/[?&]url=([^&]*)(?=&|$)/);
url = url && url[1];
url = decodeURIComponent(url).match(/[?&]url=([^&]*)(?=&|$)/);
url = url && url[1];
window.location = decodeURIComponent(url);
</script>
@brettz9
brettz9 / speechSynthesis.js
Last active August 29, 2015 14:02
Speech synthesis in Mediaiwiki; Need to put into an extension format, but easily customizable already by dropping into Common.js; replace 'gumax-nav' with ID into which to append (may also need to change element type if not a list item); also "mw-content-text" ID could be changed if not on Mediawiki or targeting something else than the main body…
/*global speechSynthesis, SpeechSynthesisUtterance*/
/*jslint vars:true, browser:true, devel:true*/
(function () {'use strict';
if (window.SpeechSynthesisUtterance) {
/*
Other properties/events:
speechSynthesis properties: pending, speaking, paused
@brettz9
brettz9 / chunkify.js
Created June 5, 2014 21:24 — forked from woollsta/chunkify.js
See https://gist.github.com/brettz9/0cfda9e04751090f4a7a for an example use on a particular Mediawiki installation (not abstracted to an extension, but could easily be so)
/**
* Chunkify
* Google Chrome Speech Synthesis Chunking Pattern
* Fixes inconsistencies with speaking long texts in speechUtterance objects
* Licensed under the MIT License
*
* Peter Woolley and Brett Zamir
*/
var speechUtteranceChunker = function (utt, settings, callback) {
// http://www.quirksmode.org/js/detect.html
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
var me = Services.wm.getMostRecentWindow(null);
Cu.import('resource://gre/modules/osfile.jsm');
var pathProfilesIni = OS.Path.join(OS.Constants.Path.userApplicationDataDir, 'profiles.ini');
me.alert(pathProfilesIni);
//apparently theres for profiles made in default prof dir:
//localDir = C:\Users\ali57233\AppData\Local\Mozilla\Firefox\Profiles\czbm1ps9.rnd1
//rootDir = C:\Users\ali57233\AppData\Roaming\Mozilla\Firefox\Profiles\czbm1ps9.rnd1
//for custom prof dir localDir and rootDir are same
@brettz9
brettz9 / jsl.html
Last active August 29, 2015 14:03
Proof-of-concept for XSL-like JavaScript class to transform HTML (the demo is JS 1.8 (Firefox only?); arrow functions won't work in this approach due to the non-binding of "this" and the short form for methods is apparently not yet implemented at least in Firefox)
<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<script src="jsl.js"></script>
</head>
<body>
<a>test</a>
<a>test2</a>
@brettz9
brettz9 / jqflower-test.html
Created July 14, 2014 22:04
Non-functioning scribbles for XQuery-like approach in JS
<!DOCTYPE html>
<meta charset="utf-8" />
<label class="myItems">Hello</label>
<label class="myItems">World!</label>
<script src="jqflower.js"></script>
<script>
try {
@brettz9
brettz9 / dot-to-dot
Created August 10, 2014 20:49
My eighth-grade Apple IIe dot-to-dot video game project (though I had another version with borders through which a dot could come out on the other side, Pac-man style). There is an Apple IIe emulator at http://www.scullinsteel.com/apple2e/ though the Apple II emulator works and can allow direct paste-in via the REPT key. (Though maybe there is a…
2 LET Z = 0
3 FOR YU = 1 TO 3
4 GR
5 B = 24:A = 10:X = 20:Y = 20
6 COLOR= 1: PLOT X,Y
7 COLOR= 2: PLOT A,B: HOME
8 COLOR= 1: IF SCRN( A,B) = 1 THEN 20000
9 HOME : PRINT "SCORE ";: PRINT Z:P = PEEK ( - 16384): POKE - 16368,0
10 IF P = 65 THEN 509
20 IF P = 21 THEN 1000
@brettz9
brettz9 / xsl-in-xhtml.js
Created December 26, 2014 21:48
XSLT in XHTML; allows self-contained XSLT 1.0 to be run from an XHTML page (without user JavaScript); currently works Firefox only (might work in IE with XSLTProcessor polyfill; other browsers had unknown problems transforming the XSLT)
/*global XSLTProcessor, DOMParser, XMLSerializer*/
/*jslint vars:true */
/*! https://mths.be/array-from v0.2.0 by @mathias */
if (!Array.from) {
(function() {
'use strict';
var defineProperty = (function() {
var result;
// IE 8 only supports `Object.defineProperty` on DOM elements.