aboutsummaryrefslogtreecommitdiffstats
path: root/chrome-get-urls-from-tabs-in-windows.js
diff options
context:
space:
mode:
authorTeddy Wing2014-03-30 16:10:01 -0400
committerTeddy Wing2014-03-30 16:10:01 -0400
commitb8aa3166e3ff74c93a97b02c204924f85b69d6be (patch)
tree3cc025b19633c07c4dd4987cc57aee286e07fa7b /chrome-get-urls-from-tabs-in-windows.js
parent9195a855b9f4a02440b70fe83addd37ff60b41ad (diff)
downloadchrome-copy-urls-from-all-tabs-b8aa3166e3ff74c93a97b02c204924f85b69d6be.tar.bz2
Add YAML output
Diffstat (limited to 'chrome-get-urls-from-tabs-in-windows.js')
-rw-r--r--chrome-get-urls-from-tabs-in-windows.js46
1 files changed, 44 insertions, 2 deletions
diff --git a/chrome-get-urls-from-tabs-in-windows.js b/chrome-get-urls-from-tabs-in-windows.js
index 0717a01..eb2f3c1 100644
--- a/chrome-get-urls-from-tabs-in-windows.js
+++ b/chrome-get-urls-from-tabs-in-windows.js
@@ -8,13 +8,55 @@ chrome.windows.getAll({populate:true}, function(windows){
chrome.storage.sync.get(function(items) {
var format = items.file_format;
- console.log(format);
if (format === 'yaml') {
+ var chrome_tabs = [];
+ windows.forEach(function(window){
+ // var window_name = 'Window ' + w_index;
+ //
+ // window.tabs.forEach(function(tab){
+ // var window_output = {};
+ // window_output[window_name] = [
+ // {
+ // page_title: tab.title,
+ // url: tab.url
+ // }
+ // ];
+ //
+ // chrome_tabs.push(window_output);
+ // });
+
+ textarea.value += "- Window " + w_index + ":\n";
+
+ window.tabs.forEach(function(tab){
+ textarea.value += " - page_title: '" + tab.title.replace('\'', '\'\'') + "'\n";
+ textarea.value += " url: '" + tab.url + "'\n";
+ });
+
+ textarea.value += "\n";
+
+ // console.log(chrome_tabs);
+ // console.log(YAML.stringify(chrome_tabs));
+ //textarea.value = YAML.stringify(chrome_tabs);
+
+ w_index++;
+ });
}
else if (format === 'html') {
-
+ windows.forEach(function(window){
+ textarea.value += "Window " + w_index + ":";
+
+ window.tabs.forEach(function(tab){
+ textarea.value += "\n";
+ textarea.value += "\t* " + tab.title + "\n";
+ textarea.value += "\t " + tab.url + "\n";
+ });
+
+ textarea.value += "\n\n";
+
+ w_index++;
+ });
}
else { // format === 'text'
windows.forEach(function(window){