Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Executes a bookmarklet from your favorites.
const noun_type_b00kmarklet = {
_name: 'b00kmarklet',
suggest: function(txt, htm, cb, sx){
if(!txt) return [];
try { var matcher = RegExp(txt, 'i') }
catch(_){ matcher = {test: function(x) ~x.indexOf(txt)} }
return [{data: b.uri, summary: b.title}
for each(b in this.list) if(matcher.test(b.title))];
init: function(){
var ls = [], {bookmarks, history} = PlacesUtils,
query = history.getNewQuery(), options = history.getNewQueryOptions();
query.onlyBookmarked = true;
query.searchTerms = 'javascript:';
({QUERY_TYPE_BOOKMARKS: options.queryType,
SORT_BY_TITLE_DESCENDING: options.sortingMode}) = options;
var {root} = history.executeQuery(query, options);
root.containerOpen = true;
for(var i = root.childCount; i--;){
var node = root.getChild(i);
if(!bookmarks.getKeywordForBookmark(node.itemId) &&
/^javascript:/.test(node.uri)) ls.push(node);
root.containerOpen = false;
this.list = ls;
return this;
name: 'bookmarklet',
synonyms: ['bml'],
icon: 'chrome://ubiquity/skin/icons/application_view_list.png',
takes: {title: noun_type_b00kmarklet},
description: 'Executes a bookmarklet from your favorites.',
help: 'Enter nothing to refresh the list.',
execute: function({data}){
if(data) CmdUtils.getWindow().location = data;
else noun_type_b00kmarklet.init();
preview: function(pbl, {data}){
pbl.innerHTML = (data
? (<div class={}
><pre style="white-space:pre-wrap;margin:2px" >{
: this.description);
author: 'satyr'.link(''), license: 'MIT',
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.