Skip to content

Instantly share code, notes, and snippets.

@jscher2000
jscher2000 / logins2csv.js
Created September 18, 2018 03:45
Dump Firefox Logins as CSV to Browser Console
// 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 / showAsPrint.js
Last active March 26, 2024 10:50
Emulate print media in Firefox 62 (userscript work in progress)
// 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 / override-atpage-margin.js
Created December 9, 2018 21:19
Override @page{margin} rules with reasonable values
// 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 / backup-maker-67.vbs
Created May 25, 2019 22:36
Firefox session history file backer upper script creator (Firefox 67+)
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 / reload_userChrome_css.js
Created July 27, 2019 01:31
Browser Console script to reload userChrome.css
/*
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 / FirefoxSaveSession.js
Last active March 18, 2024 03:08
Firefox Browser Console - Save Current Session
/* 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 / menuHotkeyChanger.js
Last active July 25, 2021 05:25
Browser Console Script to Update Copy Link accelerator key to A (which also can be used for other context menu hotkeys)
/* 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 / syncedTabsToCSV.js
Created August 31, 2021 16:10
Export Synced Tabs to CSV - Firefox Browser Console Script
// 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 / syncedTabsToBookmarksHTML.js
Last active April 9, 2024 07:10
Export Synced Tabs List to "bookmarks.html" file (Browser Console script)
// 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 / export-firefox-tab-titles-urls.js
Last active March 27, 2024 09:44
Export Current Tab Titles/URLs to CSV - Script for Firefox's Browser Console
/* Export Current Tab Titles/URLs to CSV - 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.