Skip to content

Instantly share code, notes, and snippets.

Rob Wu Rob--W

Block or report user

Report or block Rob--W

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Rob--W / manifest.json
Created Aug 2, 2019
Dummy extension to prevent elision of "http" / "file" / subdomains from the omnibox in Chrome. Use this instead of the "Suspicious Site Reporter".
View manifest.json
// This is a dummy extension that prevents elision of "http" / "file" / subdomains
// from the omnibox by impersonating the "Suspicious Site Reporter" extension.
// Do not use this if you use the "Suspicious Site Reporter" extension.
// Usage:
// 1. Create a directory, e.g. "prevent-elision-in-locationbar"
// 2. Put the content of this file as "manifest.json" in that directory.
// 3. Visit chrome://extensions, choose the "Load Unpacked" button and select the directory.
// (OR use the --load-extension=path/to/prevent-elision-in-locationbar flag to load the extension)
// Result:
Rob--W / detect-menus-viewTypes.js
Created Oct 14, 2018
Feature-detect availability of viewTypes property in browser.menus API
View detect-menus-viewTypes.js
// Example: How to feature-detect a new property (viewTypes) in the menus API
// Feature introduced in Firefox 64.
// See
// // Minimal usage example:
// let menuCreateParams = {
// title: "some menu item meant for the sidebar",
// viewTypes: ["sidebar"],
// };
// if (!supportsMenuViewTypes()) {
Rob--W / contextMenus-context-usages.txt
Created Jul 27, 2018
Usage of "contexts" in the contextMenus / menus API in public add-ons at
View contextMenus-context-usages.txt
$ ### This is a rough estimate of the values of the "contexts" array in extensions,
$ ### presumably used as values in the contextMenus/menus.create/update API.
$ ### First, we check whether the number of reported occurrences is significant,
$ ### by checking the number of "contexts:" strings that are not followed by an array.
$ ### As the first checks show, only 10% of the matches are not arrays,
$ ### (so they are variables, expressions or not part of the menus API).
$ ### The other 90% are arrays, and significant.
Rob--W / vim8_0_1272_force_rundo.diff
Created Nov 16, 2017
Patch to allow vim to use any undo file. Usage: Create a file with many blank lines and use :rundo! path/to/undo/file . Then use u or r to undo/redo
View vim8_0_1272_force_rundo.diff
commit 4775e38f78c7990306fd67fa1145433bb4779722
Author: Rob Wu <>
Date: Thu Nov 16 12:50:10 2017 +0100
Add :rundo! support
Based on
Written for
Rob--W / escaopeHTMLTag.js
Created Nov 14, 2016
Example of safe HTML escaping using template literals
View escaopeHTMLTag.js
/* Example:
var someUnsafeStr = '<img>';
var result = escapeHTMLTag`<input value="${someUnsafeStr}">`;
console.log(result); // <input value="&lt;img&gt;">
// Questions? rob {at}
// */
function escapeHTML(str) {
// Note: string cast using String; may throw if `str` is non-serializable, e.g. a Symbol.
Rob--W /
Last active Dec 10, 2017
Analysis of WOT 20151208
Rob--W /
Created Dec 9, 2015
Downloads and extracts specific npm package without dependencies or hooks.
# Downloads and extracts specific npm package without dependencies or hooks.
# Usage:
# npm-download-only [package1] [package2] ...
# where package can be a specific version (e.g. package@1.0.0) or package.
# Written on 9 dec 2015 by Rob Wu (
for arg in "$@"
Rob--W / detect-pdfjs-chromium.js
Created Sep 17, 2014
Detect whether PDF.js extension is installed in Google Chrome, Chromium or Opera.
View detect-pdfjs-chromium.js
* Detects whether the PDF.js Chromium extension is installed in the browser.
* Example: isPDFJSExtensionInstalled(function(result) { alert('Is PDF.js installed? ' + result);});
* @param {function(boolean)} callback - Called when the detection completed.
* Author: Rob Wu <> (
* Public domain - all rights waived.
function isPDFJSExtensionInstalled(callback) {
Rob--W / .hgrc
Last active Aug 29, 2015
"git commit -v" for hg (Mecurial) (appends the diff of the changeset to the hg message)
View .hgrc
# Usage: Assuming that you've saved hgeditor as ~/.mercurial/hgeditor
editor = ~/.mercurial/hgeditor
Rob--W / html5-formdata-polyfilll.js
Created May 27, 2014
FormData polyfill for Web Workers.
View html5-formdata-polyfilll.js
* FormData for XMLHttpRequest 2 - Polyfill for Web Worker
* (c) 2014 Rob Wu <>
* License: MIT
* - append(name, value[, filename])
* - XMLHttpRequest.prototype.send(object FormData)
* Specification:
* The .append() implementation also accepts Uint8Array and ArrayBuffer objects
You can’t perform that action at this time.