From dca389c6163e3b64a5cbd7b4157e038706093025 Mon Sep 17 00:00:00 2001 From: Iwasa Kazmi Date: Wed, 1 Jan 2020 00:11:38 +0900 Subject: [PATCH] updates for TB68 TB before 68 are not supported. - use "manifest.json" instead of "install.rdf" - added icon svg - options.xul doesn't use overlayed preference dialog because it is not rendered its layout correctly. - newmailalert.js was rewritten using es6 --- LICENSE | 21 +++ README | 4 - README.md | 17 ++ src/_locales/en/messages.json | 6 + src/_locales/ja/messages.json | 6 + src/chrome/content/messenger/newmailalert.js | 173 ++++++++---------- src/chrome/content/messenger/newmailalert.xul | 5 +- src/chrome/content/options.xul | 41 +++-- .../content/preferences/notifications.js | 30 +++ .../content/preferences/notifications.xul | 38 ++-- src/chrome/locale/en/common.properties | 1 - src/chrome/locale/en/notifications.dtd | 15 +- src/chrome/locale/ja/common.properties | 1 - src/chrome/locale/ja/notifications.dtd | 15 +- src/defaults/preferences/blinkingalert.js | 3 +- src/icons/icon.svg | 48 +++++ src/install.rdf | 21 --- src/manifest.json | 29 +++ 18 files changed, 298 insertions(+), 176 deletions(-) create mode 100644 LICENSE delete mode 100644 README create mode 100644 README.md create mode 100644 src/_locales/en/messages.json create mode 100644 src/_locales/ja/messages.json create mode 100644 src/chrome/content/preferences/notifications.js delete mode 100644 src/chrome/locale/en/common.properties delete mode 100644 src/chrome/locale/ja/common.properties create mode 100644 src/icons/icon.svg delete mode 100644 src/install.rdf create mode 100644 src/manifest.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..68f578f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright(c) 2007-2020 Iwasa Kazmi + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README b/README deleted file mode 100644 index f05d5e1..0000000 --- a/README +++ /dev/null @@ -1,4 +0,0 @@ -Blinking Alert --------------- - -Thunderbird add-on diff --git a/README.md b/README.md new file mode 100644 index 0000000..4c82938 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +Blinking Alert +============== + +Thunderbird add-on that adds blink feature to the new-mail alert. + +[https://addons.thunderbird.net/en-US/thunderbird/addon/blinking-alert/](https://addons.thunderbird.net/en-US/thunderbird/addon/blinking-alert/) + +## About this Add-on + +The default new-mail alert is subtle if the alert sound was turned off. +This extension adds blink feature to the new-mail alert. +You can also disable auto-hiding of the alert. + +After the extension is installed, some options are added to the "Customize New Mail Alert" dialog. +Open "Options" dialog, select "General" page, and click "Customize" button right to the "Show an alert" check box. + +If auto-hiding was disabled, you have to click close[X] button of the alert box to close it. diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json new file mode 100644 index 0000000..7f7ad1c --- /dev/null +++ b/src/_locales/en/messages.json @@ -0,0 +1,6 @@ +{ + "extensionDescription": { + "message": "Adds extra features to the new-mail alert", + "description": "Description of the extension." + } +} diff --git a/src/_locales/ja/messages.json b/src/_locales/ja/messages.json new file mode 100644 index 0000000..438f227 --- /dev/null +++ b/src/_locales/ja/messages.json @@ -0,0 +1,6 @@ +{ + "extensionDescription": { + "message": "新着メール通知に付加機能を追加します", + "description": "Description of the extension." + } +} diff --git a/src/chrome/content/messenger/newmailalert.js b/src/chrome/content/messenger/newmailalert.js index 5526cac..41b632e 100644 --- a/src/chrome/content/messenger/newmailalert.js +++ b/src/chrome/content/messenger/newmailalert.js @@ -1,7 +1,7 @@ /* * Blinking Alert * - * Copyright(c) 2007-2014 Iwasa Kazmi + * Copyright(c) 2007-2020 Iwasa Kazmi * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -22,101 +22,90 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +((window) => { -(function(window) { + const debug = false; - var debug = false; + const consoleService = window.Components.classes["@mozilla.org/consoleservice;1"] + .getService(window.Components.interfaces.nsIConsoleService); - var consoleService = Components.classes["@mozilla.org/consoleservice;1"] - .getService(Components.interfaces.nsIConsoleService); - function log(msg) { - if (debug) { - consoleService.logStringMessage("Blinking Alert : " + msg); - } + function log(msg) { + if (debug) { + consoleService.logStringMessage("Blinking Alert : " + msg); } + } + + log("addEventListener"); + + window.addEventListener("load", () => { + log("onload"); + + // original handlers + let onAlertLoadOrig = window.onAlertLoad; + let fadeOutAlertOrig = window.fadeOutAlert; + let closeAlertOrig = window.closeAlert; + + log("onAlertLoadOrig : " + typeof (onAlertLoadOrig)); + log("fadeOutAlertOrig : " + typeof (fadeOutAlertOrig)); + log("closeAlertOrig : " + typeof (closeAlertOrig)); + + // settings + let blinkInterval = 0; + let blinkColor = "#ff6600"; + let disableAutoHide = false; + let closeOnClick = false; + + // read out our initial settings from prefs. + try { + const prefBranch = window.Components.classes["@mozilla.org/preferences-service;1"] + .getService(window.Components.interfaces.nsIPrefService) + .getBranch(null); + disableAutoHide = prefBranch.getBoolPref("extensions.blinkingAlert.disableAutoHide"); + blinkInterval = prefBranch.getIntPref("extensions.blinkingAlert.blinkInterval"); + blinkColor = prefBranch.getCharPref("extensions.blinkingAlert.blinkColor"); + closeOnClick = prefBranch.getBoolPref("extensions.blinkingAlert.closeOnClick"); + } catch (ex) { } + + // replace fadeOutAlert() + window.fadeOutAlert = () => { + log("fadeOutAlert called"); + if (!disableAutoHide && fadeOutAlertOrig != null) { + log("call original fadeOutAlert"); + fadeOutAlertOrig(); + fadeOutAlertOrig = null; + } + }; + + // handle click event + window.addEventListener("click", function () { + log("onclick"); + if (closeOnClick && closeAlertOrig != null) { + log("call original closeAlert"); + closeAlertOrig(); + closeAlertOrig = null; + } + }, false); - log("addEventListener"); - - window.addEventListener("load", function() { - log("onload"); - - // original handlers - var onAlertLoadOrig = window.onAlertLoad; - var fadeOutAlertOrig = window.fadeOutAlert; - var closeAlertOrig = window.closeAlert; - - log("onAlertLoadOrig : " + typeof(onAlertLoadOrig)); - log("fadeOutAlertOrig : " + typeof(fadeOutAlertOrig)); - log("closeAlertOrig : " + typeof(closeAlertOrig)); - - // settings - var blinkInterval = 0; - var blinkColor = "#ff6600"; - var disableAutoHide = false; - var closeOnClick = false; - - // original background color - var origBackgroundColor = ''; - var hasOrigBackgroundColor = false; - - // replace fadeOutAlert() - window.fadeOutAlert = function() { - log("fadeOutAlert called"); - if (!disableAutoHide && fadeOutAlertOrig != null) { - log("call original fadeOutAlert"); - fadeOutAlertOrig(); - fadeOutAlertOrig = null; - } - }; - - // handle click event - window.addEventListener("click", function() { - log("onclick"); - if (closeOnClick && closeAlertOrig != null) { - log("call original closeAlert"); - closeAlertOrig(); - closeAlertOrig = null; - } - }, false); - - // blinking function - var blink2 = null; - var blink1 = function() { - log("blink1"); - var elem = document.getElementById("alertBox"); - if (elem) { - if (!hasOrigBackgroundColor) { - origBackgroundColor = elem.style.backgroundColor; - hasOrigBackgroundColor = true; - } - elem.style.backgroundColor = blinkColor; - setTimeout(blink2, blinkInterval); - } - }; - - blink2 = function() { - log("blink2"); - var elem = document.getElementById("alertBox"); - if (elem) { - elem.style.backgroundColor = origBackgroundColor; - setTimeout(blink1, blinkInterval); - } - }; - - // read out our initial settings from prefs. - try { - var prefBranch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch(null); - disableAutoHide = prefBranch.getBoolPref("extensions.blinkingAlert.disableAutoHide"); - blinkInterval = prefBranch.getIntPref ("extensions.blinkingAlert.blinkInterval"); - blinkColor = prefBranch.getCharPref("extensions.blinkingAlert.blinkColor"); - closeOnClick = prefBranch.getBoolPref("extensions.blinkingAlert.closeOnClick"); - } catch (ex) {} - - // set time to start blinking - if (blinkInterval > 0) { - log("start blinking"); - setTimeout(blink1, 0); + // blinking function + const blink = (origBgColor) => { + log("blink"); + const elem = window.document.getElementById("alertBox"); + if (elem) { + if (origBgColor !== null) { + elem.style.backgroundColor = origBgColor; + origBgColor = null; + } else { + origBgColor = elem.style.backgroundColor; + elem.style.backgroundColor = blinkColor; } - }, false); + window.setTimeout(() => blink(origBgColor), blinkInterval); + } + }; + + // start blinking + if (blinkInterval > 0) { + log("start blinking"); + window.setTimeout(() => blink(null), 0); + } + }, false); })(window); - diff --git a/src/chrome/content/messenger/newmailalert.xul b/src/chrome/content/messenger/newmailalert.xul index 1ef0803..f14d3e7 100644 --- a/src/chrome/content/messenger/newmailalert.xul +++ b/src/chrome/content/messenger/newmailalert.xul @@ -3,7 +3,7 @@ /* * Blinking Alert * - * Copyright(c) 2007-2014 Iwasa Kazmi + * Copyright(c) 2007-2020 Iwasa Kazmi * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -27,6 +27,5 @@ --> -