Skip to content

Instantly share code, notes, and snippets.

@jscher2000
jscher2000 / syncedTabsToBookmarksHTML.js
Last active Sep 15, 2021
Export Synced Tabs List to "bookmarks.html" file (Browser Console script)
View syncedTabsToBookmarksHTML.js
// Run code in Browser Console after enabling chrome debugging --
// about:config => devtools.chrome.enabled => true
// https://developer.mozilla.org/docs/Tools/Browser_Console
try {
var tabPromise = SyncedTabs._internal.getTabClients();
tabPromise.then((arrDevices) => {
if (arrDevices && arrDevices.length > 0){
// Generate a string with the format of a bookmark export file
var d, e, out = '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n<TITLE>Bookmarks</TITLE>\n<H1>Bookmarks Menu</H1>\n<DL><p>\n';
const escapeHtmlEntities = function(aText){return (aText || '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;')};
@jscher2000
jscher2000 / syncedTabsToCSV.js
Created Aug 31, 2021
Export Synced Tabs to CSV - Firefox Browser Console Script
View syncedTabsToCSV.js
// Run code in Browser Console after enabling chrome debugging --
// about:config => devtools.chrome.enabled => true
// ** first device only **
try {
var tabPromise = SyncedTabs._internal.getTabClients();
tabPromise.then((arrTabs) => {
if (arrTabs && arrTabs.length > 0){
var csv = 'Tabs from: ' + arrTabs[0].name + '\n\n"Title","URL"';
for (var i=0; i<arrTabs[0].tabs.length; i++){
csv += '\n';
@jscher2000
jscher2000 / menuHotkeyChanger.js
Last active Jul 25, 2021
Browser Console Script to Update Copy Link accelerator key to A (which also can be used for other context menu hotkeys)
View menuHotkeyChanger.js
/* Script for the Browser Console
NOTE: BEFORE RUNNING THIS SCRIPT, CHECK THIS SETTING:
Type or paste about:config into the address bar and press Enter
Click the button promising to be careful
In the search box paste devtools.chrome.enabled
If the preference is false, double-click it to toggle to true
Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j)
Then press Enter to run the script.
@jscher2000
jscher2000 / FirefoxSaveSession.js
Last active Sep 14, 2021
Firefox Browser Console - Save Current Session
View FirefoxSaveSession.js
/* Session Backup Script for the Browser Console
NOTE: BEFORE RUNNING THIS SCRIPT, CHECK THIS SETTING:
Type or paste about:config into the address bar and press Enter
Click the button promising to be careful
In the search box type devt and pause while Firefox filters the list
If devtools.chrome.enabled is false, double-click it to toggle to true
Paste this entire script into the command line at the bottom of the Browser Console (Windows: Ctrl+Shift+j)
Then press Enter to run the script. A save dialog should promptly open.
@jscher2000
jscher2000 / reload_userChrome_css.js
Created Jul 27, 2019
Browser Console script to reload userChrome.css
View reload_userChrome_css.js
/*
Code to paste and run in the Browser Console
Requires devtools.chrome.enabled => true in about:config
Tested in Firefox 68.0.1 on Windows
*/
// Create references to APIs we'll use
var ss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
var io = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var ds = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
@jscher2000
jscher2000 / backup-maker-67.vbs
Created May 25, 2019
Firefox session history file backer upper script creator (Firefox 67+)
View backup-maker-67.vbs
Option Explicit
' Creates a Backup Script named Fx-backup-recoveryJS(profilefoldername).vbs in your (My) Documents folder to copy
' recovery.jsonlz4 or sessionstore.jsonlz4 from your default profile to an FxSessions folder in your (My) Documents folder
' v0.3 - 25 May 2019 - jscher2000 - MPL 2.0 license
Dim oShell, sAppData, sDocsFolder
' Get APPDATA path and My Documents path
Set oShell = CreateObject("Wscript.Shell")
sAppData = oShell.expandEnvironmentStrings("%APPDATA%") + "\Mozilla\Firefox"
sDocsFolder = oShell.SpecialFolders.Item("MyDocuments")
' Check for Firefox's installs.ini file
@jscher2000
jscher2000 / override-atpage-margin.js
Created Dec 9, 2018
Override @page{margin} rules with reasonable values
View override-atpage-margin.js
// Override @page{margin} rule if found
var docSS = document.styleSheets, ss, ess;
for (var i=0; i<docSS.length; i++){
if (!docSS[i].disabled){
// check content of style sheet for @page (type 6 style sheet)
// https://developer.mozilla.org/en-US/docs/Web/API/CSSRule#Type_constants
ss = docSS[i];
for (var j=0; j<ss.cssRules.length; j++){
if (ss.cssRules[j].type == 6){ // Page sheet
if (ss.cssRules[j].cssText.indexOf('margin') > -1){
@jscher2000
jscher2000 / showAsPrint.js
Last active Jul 28, 2020
Emulate print media in Firefox 62 (userscript work in progress)
View showAsPrint.js
// For Firefox's Web Console, creates the functions showAsPrint() and undoShowAsPrint()
// to roughly emulate print media and revert
function showAsPrint(){
var docSS = document.styleSheets, ss, oldMedia, newMedia, rules;
var p2s = function(media){
if (media.indexOf('all') > -1) return media; //no need to change
if (media == 'print') return 'all, wasprint'; //show on screen, too
if (media.indexOf('print') > -1 && media.indexOf('screen') > -1) return media; //no need to change
if (media == 'screen') return 'wasscreen'; //hide these rules
if (media.indexOf('screen') > -1) return media.replace('screen', 'wasscreen'); //hide these rules
@jscher2000
jscher2000 / logins2csv.js
Created Sep 18, 2018
Dump Firefox Logins as CSV to Browser Console
View logins2csv.js
// Run code in Browser Console after enabling Chrome Debugging --
// about:config => devtools.chrome.enabled => true
try {
signons = Services.logins.getAllLogins();
var csv = '"Site","Username","Password"';
for (var i=0; i<signons.length; i++){
csv += '\n';
csv += signons[i].httpRealm ?
('"' + signons[i].hostname + ' (' + signons[i].httpRealm + ')","') :
'"' + signons[i].hostname + '","';
@jscher2000
jscher2000 / gist:3ff0d847db967a3d8c2385a5de05a677
Created Apr 6, 2018
Fix Gmail Message Times When Resisting Fingerprinting (user script / pre-alpha)
View gist:3ff0d847db967a3d8c2385a5de05a677
// ==UserScript==
// @name Fix Gmail Message Times When Resisting Fingerprinting
// @author Jefferson "jscher2000" Scher
// @namespace JeffersonScher
// @version 0.1 Pre-Alpha
// @copyright Copyright 2018 Jefferson Scher
// @license BSD-3-Clause
// @include https://mail.google.com/mail/*
// @grant GM_registerMenuCommand
// ==/UserScript==