Skip to content

Instantly share code, notes, and snippets.

View darktrojan's full-sized avatar

Geoff Lankow darktrojan

View GitHub Profile
@darktrojan
darktrojan / gist:d76dd0da21f45073f1bb
Last active August 29, 2015 14:15
HTTPS redirector thing
Components.utils.import("resource://gre/modules/Services.jsm");
let redirects;
let pref = {
name: "extensions.something.pref",
init: function() {
this.readPref();
Services.prefs.addObserver(this.name, this, false);
},
@darktrojan
darktrojan / frecency.js
Last active May 14, 2018 23:54
Recalculate frecency score for all places
var start = Date.now();
var cutoff = (Date.now() - 180 * 86400000) * 1000;
var min_frecency = 50;
PlacesUtils.history.DBConnection.createAsyncStatement(
'UPDATE moz_places SET ' +
'visit_count = MAX((SELECT COUNT(*) FROM moz_historyvisits WHERE place_id = moz_places.id AND visit_date > ' + cutoff + '), 1) ' +
'WHERE frecency > ' + min_frecency
).executeAsync({
handleCompletion: function() {
PlacesUtils.history.DBConnection.createAsyncStatement(
@darktrojan
darktrojan / zoom.js
Created July 17, 2012 23:53
zoom to fit the viewport width from metadata
{
let ww = gBrowser.selectedBrowser.boxObject.width;
let wu = gBrowser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
let w = parseFloat(wu.getDocumentMetadata("viewport-width"));
//gBrowser.contentDocument.documentElement.style.width = w + 'px';
if (!isNaN(w))
ZoomManager.zoom = ww/w;
}