ui-help.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright 2010-2020 Gildas Lormeau
  3. * contact : gildas.lormeau <at> gmail.com
  4. *
  5. * This file is part of SingleFile.
  6. *
  7. * The code in this file is free software: you can redistribute it and/or
  8. * modify it under the terms of the GNU Affero General Public License
  9. * (GNU AGPL) as published by the Free Software Foundation, either version 3
  10. * of the License, or (at your option) any later version.
  11. *
  12. * The code in this file is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
  15. * General Public License for more details.
  16. *
  17. * As additional permission under GNU AGPL version 3 section 7, you may
  18. * distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU
  19. * AGPL normally required by section 4, provided you include this license
  20. * notice and a URL through which recipients can access the Corresponding
  21. * Source.
  22. */
  23. /* global browser, document */
  24. let BACKGROUND_SAVE_SUPPORTED,
  25. AUTO_SAVE_SUPPORTED,
  26. OPEN_SAVED_PAGE_SUPPORTED,
  27. AUTO_OPEN_EDITOR_SUPPORTED,
  28. INFOBAR_SUPPORTED,
  29. BOOKMARKS_API_SUPPORTED,
  30. IDENTITY_API_SUPPORTED,
  31. CLIPBOARD_API_SUPPORTED,
  32. NATIVE_API_API_SUPPORTED,
  33. WEB_BLOCKING_API_SUPPORTED,
  34. SELECTABLE_TABS_SUPPORTED;
  35. browser.runtime.sendMessage({ method: "config.getConstants" }).then(data => {
  36. ({
  37. BACKGROUND_SAVE_SUPPORTED,
  38. AUTO_SAVE_SUPPORTED,
  39. OPEN_SAVED_PAGE_SUPPORTED,
  40. AUTO_OPEN_EDITOR_SUPPORTED,
  41. INFOBAR_SUPPORTED,
  42. BOOKMARKS_API_SUPPORTED,
  43. IDENTITY_API_SUPPORTED,
  44. CLIPBOARD_API_SUPPORTED,
  45. NATIVE_API_API_SUPPORTED,
  46. WEB_BLOCKING_API_SUPPORTED,
  47. SELECTABLE_TABS_SUPPORTED
  48. } = data);
  49. init();
  50. });
  51. function init() {
  52. if (!AUTO_SAVE_SUPPORTED) {
  53. document.getElementById("autoSaveSection").hidden = true;
  54. document.getElementById("autoSaveOptions").hidden = true;
  55. document.getElementById("autoSaveMenu").hidden = true;
  56. document.getElementById("autoSaveHint").hidden = true;
  57. }
  58. if (!BACKGROUND_SAVE_SUPPORTED) {
  59. document.getElementById("backgroundSaveOption").hidden = true;
  60. document.getElementById("confirmFilenameOption").hidden = true;
  61. document.getElementById("filenameConflictActionOption").hidden = true;
  62. }
  63. if (!BOOKMARKS_API_SUPPORTED) {
  64. document.getElementById("bookmarksSection").hidden = true;
  65. document.getElementById("bookmarksOptions").hidden = true;
  66. }
  67. if (!OPEN_SAVED_PAGE_SUPPORTED) {
  68. document.getElementById("openSavedPageOption").hidden = true;
  69. }
  70. if (!AUTO_OPEN_EDITOR_SUPPORTED) {
  71. document.getElementById("autoOpenEditorOption").hidden = true;
  72. }
  73. if (!INFOBAR_SUPPORTED) {
  74. document.getElementById("displayInfobarOption").hidden = true;
  75. }
  76. if (!IDENTITY_API_SUPPORTED) {
  77. document.getElementById("saveToGDriveOption").hidden = true;
  78. document.getElementById("saveToGDriveHint").hidden = true;
  79. }
  80. if (!CLIPBOARD_API_SUPPORTED) {
  81. document.getElementById("saveToClipboardOption").hidden = true;
  82. }
  83. if (!NATIVE_API_API_SUPPORTED) {
  84. document.getElementById("saveWithCompanionOption").hidden = true;
  85. }
  86. if (!WEB_BLOCKING_API_SUPPORTED) {
  87. document.getElementById("passReferrerOnErrorOption").hidden = true;
  88. }
  89. if (!SELECTABLE_TABS_SUPPORTED) {
  90. document.getElementById("selectableTabsMenu").hidden = true;
  91. document.getElementById("shortcutsSection").hidden = true;
  92. }
  93. }