Yank all buffer uris
Hello,
I've been trying to add in some code to yank the urls of all opened tabs,
but I haven't had any success. I'm a C programmer and completely lost in this
confusing javascript world. I'm getting "undefined" for anything that I try,
when iterating through the array of uris and what not, returned from tabs.js.
I've attached a patch with my attempts, if anyone is interested in taking
a look.
Thanks,
Rob
diff -r 482aa8084e0e common/content/browser.js
--- a/common/content/browser.js Tue Jan 10 21:24:47 2012 +0900
+++ b/common/content/browser.js Tue Jan 10 22:24:08 2012 +0000
@@ -100,6 +101,19 @@
["y"], "Yank current location to the clipboard",
function () { util.copyToClipboard(util.losslessDecodeURI(buffer.URL, 'conservative'), true); });
+ mappings.add([modes.NORMAL],
+ ["gya"], "Yank all locations to the clipboard",
+ function () {
+ let allUris = "";
+ let buffers = tabs.get();
+
+ for (var buf in buffers) {
+ allUris += buf[3] + "\n";
+ }
+
+ util.copyToClipboard(allUris, true);
+ });
+
// opening websites
mappings.add([modes.NORMAL],
["o"], "Open one or more URLs",
diff -r 482aa8084e0e common/content/tabs.js
--- a/common/content/tabs.js Tue Jan 10 21:24:47 2012 +0900
+++ b/common/content/tabs.js Tue Jan 10 22:24:08 2012 +0000
@@ -131,7 +131,8 @@
let title = browser.contentTitle || "(Untitled)";
let uri = browser.currentURI.spec;
let number = i + 1;
- buffers.push([number, title, uri]);
+ let host = browser.currentURI.host;
+ buffers.push([number, title, uri, host]);
}
return buffers;
},