Skip to content

Commit

Permalink
Explicitly test for availability of the bookmark API
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Mar 17, 2018
1 parent 9c1c39c commit dc333d7
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Martin Väth <martin at mvath.de>:
- Major layout change: Use textarea instead of input field
- Minor layout changes: Warning placement, table head, arrows
- Explicitly test for availability of the bookmark API
- Fixed minor mistakes in DOM tree which worked only by accident
- Internal: use generic wrapper functions for DOM appending
- Internal: use clean HTML5 which passes https://validator.w3.org/
Expand Down
4 changes: 4 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "Anzeige/Entfernung doppelter Lesezeichen, leerer Ordner oder Beschreibungen",
"description": "Description of the extension"
},
"errorNoBookmarks": {
"message": "Diese Browser-Version besitzt nicht die benötigte Lesezeichen-API. Erweiterungen wie „Lesezeichenduplikate“ können ohne diese API leider nicht funktionieren.",
"description": "Report that the extension will not work on that browser"
},
"warningExpertStrong": {
"message": "\u26A0\u00A0",
"description": "First part of warning to enable expert mode: strong"
Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "Display/Remove duplicate bookmarks, empty folders, or descriptions",
"description": "Description of the extension"
},
"errorNoBookmarks": {
"message": "This browser version is lacking the required bookmarks API. Bookmark Dupes and similar extensions cannot work without that API. Sorry.",
"description": "Report that the extension will not work on that browser"
},
"warningExpertStrong": {
"message": "\u26A0\u00A0",
"description": "First part of warning to enable expert mode: strong"
Expand Down
4 changes: 4 additions & 0 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "Mostrar/Eliminar marcadores duplicados, carpetas vacías, o descripciones",
"description": "Description of the extension"
},
"errorNoBookmarks": {
"message": "This browser version is lacking the required bookmarks API. Bookmark Dupes and similar extensions cannot work without that API. Sorry.", // new
"description": "Report that the extension will not work on that browser"
},
"warningExpertStrong": {
"message": "\u26A0\u00A0",
"description": "First part of warning to enable expert mode: strong"
Expand Down
4 changes: 4 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "Поиск, отображение и удаление дублей закладок, пустых папок, описаний",
"description": "Description of the extension"
},
"errorNoBookmarks": {
"message": "This browser version is lacking the required bookmarks API. Bookmark Dupes and similar extensions cannot work without that API. Sorry.", // new
"description": "Report that the extension will not work on that browser"
},
"warningExpertStrong": {
"message": "\u26A0\u00A0",
"description": "First part of warning to enable expert mode: strong"
Expand Down
4 changes: 4 additions & 0 deletions _locales/uk/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "Пошук, відображення та видалення дублів закладок, порожніх папок або описів",
"description": "Description of the extension"
},
"errorNoBookmarks": {
"message": "This browser version is lacking the required bookmarks API. Bookmark Dupes and similar extensions cannot work without that API. Sorry.", // new
"description": "Report that the extension will not work on that browser"
},
"warningExpertStrong": {
"message": "\u26A0\u00A0",
"description": "First part of warning to enable expert mode: strong"
Expand Down
4 changes: 4 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
"message": "显示/移除重复的书签、空文件夹或描述",
"description": "Description of the extension"
},
"errorNoBookmarks": {
"message": "This browser version is lacking the required bookmarks API. Bookmark Dupes and similar extensions cannot work without that API. Sorry.", // new
"description": "Report that the extension will not work on that browser"
},
"warningExpertStrong": {
"message": "\u26A0\u00A0", // new
"description": "First part of warning to enable expert mode: strong"
Expand Down
16 changes: 15 additions & 1 deletion data/tab/dupes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,16 @@ function storageListener(changes, storageArea) {
buttonsRules(storageArea);
}

{
function checkCompatibility() {
if (browser && browser.bookmarks && browser.bookmarks.getTree &&
typeof(browser.bookmarks.getTree) == "function") {
return true;
}
displayMessage(browser.i18n.getMessage("errorNoBookmarks"));
return false;
}

function initMain() {
// state variables
let state = {};
let rules;
Expand Down Expand Up @@ -2421,10 +2430,15 @@ function storageListener(changes, storageArea) {
const title = browser.i18n.getMessage("extensionName");
setTitle(title);
setHeadTitle(title, browser.i18n.getMessage("extensionDescription"));
if (!checkCompatibility()) {
return;
}
addButtonsBase();
document.addEventListener("CheckboxStateChange", checkboxListener);
document.addEventListener("click", clickListener);
document.addEventListener("change", changeListener);
browser.storage.onChanged.addListener(storageListener);
endLock();
}

initMain();

0 comments on commit dc333d7

Please sign in to comment.