Skip to content

Instantly share code, notes, and snippets.

@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.
@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 / decompress-mozlz4-snippet.js
Last active March 18, 2024 03:10
Browser Console Snippet to decompress mozlz4 and jsonlz4 files
/* Decompression 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 file picker should promptly open.
@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 / 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 / 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 / mailto-yahoo-2023.js
Created June 18, 2023 19:16
Add handler for Firefox via Browser Console - Yahoo! Mail example
/* Add Handler via Firefox Browser Console -- mailto: Yahoo! Mail
NOTE: BEFORE YOU CAN RUN THIS SCRIPT, IF YOU HAVEN'T ALREADY:
* 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 dialog should pop indicating whether the save was successful.
@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 / scroungehistory.js
Created June 18, 2017 17:33
Console Script to Scrounge Title and URLs from a Firefox Session History File
/* Open old session history file in a tab, open the web console, paste all of this, press Enter to execute.
If popup is blocked, allow popups then try again. */
function scrub(t){t=t.replace(/&/g,'&amp;'); t=t.replace(/>/g,'&gt;'); t=t.replace(/</g,'&lt;'); return t;}
if (window.confirm('Scrounge session URLs?')) var newwin=window.open();
if (newwin){
newwin.document.write('<!DOCTYPE html>\n<html><head><title>URLs Scrounged from Session History</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=UTF-8\'><style>.urllist>p{margin-left:2.25em}.urllist>p:nth-of-type(1){margin-left:0}</style></head>\n');
newwin.document.write('<body><h1>URLs Scrounged from Session History</h1>\n');
var out=new Array();
var sess=document.body.textContent.split('"_closedWindows":[');
console.log(sess.length);