aboutsummaryrefslogtreecommitdiffstats
path: root/commandBookmarklet.js
diff options
context:
space:
mode:
Diffstat (limited to 'commandBookmarklet.js')
-rw-r--r--commandBookmarklet.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/commandBookmarklet.js b/commandBookmarklet.js
new file mode 100644
index 0000000..e279b32
--- /dev/null
+++ b/commandBookmarklet.js
@@ -0,0 +1,37 @@
+/**
+ * bookmarklet wo command ni suru plugin
+ *
+ * @author halt feits <halt.feits@gmail.com>
+ * @version 0.6.0
+ */
+
+(function(){
+ var filter = "javascript:";
+ var items = liberator.bookmarks.get(filter);
+
+ if (items.length == 0) {
+ if (filter.length > 0) {
+ liberator.echoerr("E283: No bookmarks matching \"" + filter + "\"");
+ } else {
+ liberator.echoerr("No bookmarks set");
+ }
+ }
+
+ for (var i = 0; i < items.length; i++) {
+ var title = liberator.util.escapeHTML(items[i][1]);
+ if (title.length > 50) {
+ title = title.substr(0, 47) + "...";
+ }
+
+ var url = liberator.util.escapeHTML(items[i][0]);
+ var command = new Function('', 'liberator.open("' + url + '");');
+ liberator.commands.addUserCommand(
+ [title],
+ 'bookmarklet',
+ command,
+ {
+ shortHelp: 'bookmarklet',
+ }
+ );
+ }
+})();