Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save collection to bookmarks #74

Open
wants to merge 7 commits into
base: major-3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ This project has adopted the Contributor Covenant. For more information see the

Font copyrights: Microsoft Corportation ©2021 (Additional ELUA applied)

Licensed under [MIT License](https://opensource.org/licenses/MIT)
Licensed under [MIT License](https://opensource.org/licenses/MIT)
10 changes: 10 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"message": "Restore without removing",
"description": "Context action item name"
},
"saveCollectionAsBookmarks":
{
"message": "Save as bookmarks",
"description": "Button allowing the user to save a collection in the browser bookmarks"
},
"collectionSavedAsBookmarks":
{
"message": "The collection has been saved in your bookmark bar.",
"description": "Alert dialog message when a user has saved a collection in the browser bookmarks"
},
"removeCollection":
{
"message": "Remove collection",
Expand Down
12 changes: 11 additions & 1 deletion _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"message": "Restaurar sin eliminar",
"description": "Context action item name"
},
"saveCollectionAsBookmarks":
{
"message":"Guardar como marcadores",
"description":"Button allowing the user to save a collection in the browser bookmarks"
},
"collectionSavedAsBookmarks":
{
"message":"La colección se ha guardado en la barra de marcadores. .",
"description":"Alert dialog message when a user has saved a collection in the browser bookmarks"
},
"removeCollection":
{
"message": "Eliminar la colección",
Expand Down Expand Up @@ -139,4 +149,4 @@
"message": "items",
"description": "Collection tabs counter label (e.g. 8 items)"
}
}
}
10 changes: 10 additions & 0 deletions _locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"message": "Ripristina senza rimuovere le schede da da Tabs Aside",
"description": "Context action item name"
},
"saveCollectionAsBookmarks":
{
"message":"Salva come segnalibri",
"description":"Button allowing the user to save a collection in the browser bookmarks"
},
"collectionSavedAsBookmarks":
{
"message":"La raccolta è stata salvata nella barra dei preferiti.",
"description":"Alert dialog message when a user has saved a collection in the browser bookmarks"
},
"removeCollection":
{
"message": "Rimuovi gruppo di schede",
Expand Down
10 changes: 10 additions & 0 deletions _locales/pt_BR/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"message": "Restaurar sem remover",
"description": "Context action item name"
},
"saveCollectionAsBookmarks":
{
"message": "Salvar como marcadores",
"description": "Button allowing the user to save a collection in the browser bookmarks"
},
"collectionSavedAsBookmarks":
{
"message": "A coleção foi salva na sua barra de marcadores.",
"description": "Alert dialog message when a user has saved a collection in the browser bookmarks"
},
"removeCollection":
{
"message": "Remover coleção",
Expand Down
10 changes: 10 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"message": "Восстановить без удаления",
"description": "Context action item name"
},
"saveCollectionAsBookmarks":
{
"message": "Сохранить в избранное",
"description": "Button allowing the user to save a collection in the browser bookmarks"
},
"collectionSavedAsBookmarks":
{
"message": "Коллекция добавлена в избранное",
"description": "Alert dialog message when a user has saved a collection in the browser bookmarks"
},
"removeCollection":
{
"message": "Удалить коллекцию",
Expand Down
10 changes: 10 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@
"message": "恢复但不移除标签页",
"description": "Context action item name"
},
"saveCollectionAsBookmarks":
{
"message":"另存为书签",
"description":"Button allowing the user to save a collection in the browser bookmarks"
},
"collectionSavedAsBookmarks":
{
"message":"收藏已保存在您的书签栏中.",
"description":"Alert dialog message when a user has saved a collection in the browser bookmarks"
},
"removeCollection":
{
"message": "移除标签页集",
Expand Down
2 changes: 1 addition & 1 deletion css/style.listview.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
.tabsAside[listview] .listviewSwitch.list > div
{
background-color: gray;
}
}
15 changes: 15 additions & 0 deletions js/aside-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ function AddCollection(collection, thumbnails)
"<button loc_alt='more' class='btn more' title='More...'>&#xE712;</button>" +
"<nav>" +
"<button loc='restoreNoRemove' class='restoreCollection noDelete'>Restore without removing</button>" +
"<button loc='saveCollectionAsBookmarks' class='saveCollectionAsBookmarks'>Save as bookmarks</button>" +
"</nav>" +
"</div>" +
"<button loc_alt='removeCollection' class='btn remove' title='Remove collection'>&#xE711;</button>" +
Expand All @@ -290,6 +291,9 @@ function AddCollection(collection, thumbnails)
list.querySelectorAll(".restoreCollection.noDelete").forEach(i =>
i.onclick = () => RestoreTabs(i.parentElement.parentElement.parentElement.parentElement, false));

list.querySelectorAll(".saveCollectionAsBookmarks").forEach(i =>
i.onclick = () => SaveCollectionAsBookmarks(i.parentElement.parentElement.parentElement.parentElement));

list.querySelectorAll(".set > div").forEach(i =>
i.onclick = (args) =>
{
Expand Down Expand Up @@ -325,6 +329,17 @@ function RenameCollection(collectionData, name)
});
}

function SaveCollectionAsBookmarks(collectionData)
{
chrome.runtime.sendMessage(
{
command: "SaveCollectionAsBookmarks",
collectionKey: collectionData.id
},
() => alert(chrome.i18n.getMessage("collectionSavedAsBookmarks"))
);
}

function RestoreTabs(collectionData, removeCollection = true)
{
chrome.runtime.sendMessage(
Expand Down
32 changes: 21 additions & 11 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,27 @@ function MergePreV2Collections ()

function SaveCollectionAsBookmarks (collection)
{
var collectionTitle = (collection.name ?? "") + "(" + new Date(collection.timestamp).toLocaleString() + ")";
//The id 1 is the browser's bookmark bar
chrome.bookmarks.create({
"parentId": "1",
"title": "TabsAside " + (collection.name ?? new Date(collection.timestamp).toISOString())
},
(collectionFolder) =>
"title": "Tabs aside"
}, (tabsAsideFolder) =>
{
for (var i = 0; i < collection.links.length; i++)
chrome.bookmarks.create(
{
"parentId": collectionFolder.id,
"title": collection.titles[i],
"url": collection.links[i]
});
});
chrome.bookmarks.create({
"parentId": tabsAsideFolder.id,
"title": collectionTitle
}, (collectionFolder) =>
{
for (var i = 0; i < collection.links.length; i++)
chrome.bookmarks.create(
{
"parentId": collectionFolder.id,
"title": collection.titles[i],
"url": collection.links[i]
});
});
})
}

LoadStorages(MergePreV2Collections);
Expand Down Expand Up @@ -320,6 +326,10 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) =>
collections[message.collectionKey].name = message.newName;
UpdateStorages({ [message.collectionKey]: collections[message.collectionKey] });
break;
case "SaveCollectionAsBookmarks":
SaveCollectionAsBookmarks(collections[message.collectionKey]);
sendResponse();
break;
case "togglePane":
chrome.tabs.query(
{
Expand Down