diff --git a/LICENSE b/LICENSE index d4879b0..347492a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License -Copyright (c) 2016 Icaro Perseo +Copyright (c) 2017, Iván Ruvalcaba +Copyright (c) 2014, Namolovan Nicolae (https://twitter.com/NicolaeNMV) 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 diff --git a/README.markdown b/README.md similarity index 61% rename from README.markdown rename to README.md index 763c569..336ba0a 100644 --- a/README.markdown +++ b/README.md @@ -1,12 +1,12 @@ [//]: # (Filename: README.md) -[//]: # (Author: Icaro Perseo) -[//]: # (Contact: ) +[//]: # (Author: Iván Ruvalcaba) +[//]: # (Contact: ) [//]: # (Created: 26 dic 2016 16:50:04) -[//]: # (Last Modified: 27 dic 2016 11:49:52) +[//]: # (Last Modified: 03 sep 2017 18:52:30) -# Behind The Overlay Revival —Mozilla Firefox and Google Chrome Web Extension— +# Behind The Overlay Revival —Mozilla Firefox WebExtension— -> This project is a fork of [Behind The Overlay](https://github.com/NicolaeNMV/BehindTheOverlay) add-on, ported as web extension for _Mozilla Firefox_ as well as some improvements implemented for both web browsers. +> This project is a fork of [Behind The Overlay](https://github.com/NicolaeNMV/BehindTheOverlay) add-on, ported as _Mozilla Firefox WebExtension_ as well as some improvements implemented. ## What's it all about? @@ -16,9 +16,9 @@ I find this very annoying as every site will have a different way to close that This extension solves this problem by offering you **one button to close any overlay on any website** you may ever encounter. -## Web Extension in action +## WebExtension in action -Behind The Overlay Revival in action +![](docs/bor.jpg "Remove overlay") ## Does it work everywhere ? @@ -34,14 +34,11 @@ The extension should work on all sites that have overlays. ## Changelog -* [x] Porting the original complement as _Firefox Web Extension_. -* [x] Fix minor issues (typos). -* [x] Improve the original code (just a bit). -* [x] Add _Behind The Overlay Revival_ to context menu. -* [x] Add to _Behind The Overlay Revival_ one shortcut (`Alt + Shift + x`). -* [x] English/Spanish translations added (locale support). -* [ ] Add user menu to change the default shortcut. -* [ ] Add site whitelist/blacklist support (**on user demand**). ++ Porting the original complement as _Firefox Web Extension_. ++ Improved the original code. ++ Add to _Behind The Overlay Revival_ one shortcut (`Alt + Shift + x`). ++ English/Spanish translations added (locale support). ++ Implemented a clickable icon inside the browser's address bar (`pageAction`). ## Feedback diff --git a/design/logo.png b/design/logo.png deleted file mode 100644 index 312dedf..0000000 Binary files a/design/logo.png and /dev/null differ diff --git a/design/logo.svg b/design/logo.svg deleted file mode 100644 index 948761f..0000000 --- a/design/logo.svg +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - diff --git a/docs/bor.jpg b/docs/bor.jpg new file mode 100644 index 0000000..74e13e8 Binary files /dev/null and b/docs/bor.jpg differ diff --git a/resources/bor.png b/docs/logo.png similarity index 100% rename from resources/bor.png rename to docs/logo.png diff --git a/extension/_locales/en/messages.json b/extension/_locales/en/messages.json index 49fa1c4..5f0b7ca 100644 --- a/extension/_locales/en/messages.json +++ b/extension/_locales/en/messages.json @@ -3,16 +3,16 @@ "message": "Click to close any overlay popup on any website.", "description": "Description of the extension." }, - "defaultBrowserActionTitle": { - "message": "Remove the overlay from this page", + "defaultPageActionTitle": { + "message": "Remove the overlay from this page.", "description": "Description of the browser action." }, "suggestedKeyTitle": { - "message": "Remove the overlay from this page", + "message": "Remove the overlay from this page.", "description": "Description of the suggested key." }, - "contextMenuRemoveOverlayTitle": { - "message": "Remove the overlay from this page", - "description": "Description of the context menu remove overlay." + "noOverlayAlertMessage": { + "message": "No overlay has been found on this website.", + "description": "Description of alert message." } } diff --git a/extension/_locales/es/messages.json b/extension/_locales/es/messages.json index 8d6d9ba..b1c6679 100644 --- a/extension/_locales/es/messages.json +++ b/extension/_locales/es/messages.json @@ -3,16 +3,16 @@ "message": "Cierre el mensaje emergente de algún sitio web con un solo clic.", "description": "Description of the extension." }, - "defaultBrowserActionTitle": { - "message": "Cerrar el mensaje emergente de esta página", + "defaultPageActionTitle": { + "message": "Cerrar el mensaje emergente de esta página.", "description": "Description of the browser action." }, "suggestedKeyTitle": { - "message": "Cerrar el mensaje emergente de esta página", + "message": "Cerrar el mensaje emergente de esta página.", "description": "Description of the suggested key." }, - "contextMenuRemoveOverlayTitle": { - "message": "Cerrar el mensaje emergente de esta página", - "description": "Description of the context menu remove overlay." + "noOverlayAlertMessage": { + "message": "No se encontró ningún mensaje emergente en esta página.", + "description": "Description of alert message." } } diff --git a/extension/img/close.svg b/extension/img/close.svg new file mode 100644 index 0000000..d7dbfb4 --- /dev/null +++ b/extension/img/close.svg @@ -0,0 +1,75 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/extension/img/icon-16.png b/extension/img/icon-16.png deleted file mode 100644 index 56727ba..0000000 Binary files a/extension/img/icon-16.png and /dev/null differ diff --git a/extension/img/icon-19.png b/extension/img/icon-19.png deleted file mode 100644 index 2f7dfa0..0000000 Binary files a/extension/img/icon-19.png and /dev/null differ diff --git a/extension/img/icon-38.png b/extension/img/icon-38.png deleted file mode 100644 index 84ba1d3..0000000 Binary files a/extension/img/icon-38.png and /dev/null differ diff --git a/extension/img/icon.png b/extension/img/icon.png deleted file mode 100644 index 9d11ed0..0000000 Binary files a/extension/img/icon.png and /dev/null differ diff --git a/extension/img/icon@2x.png b/extension/img/icon@2x.png deleted file mode 100644 index 14558b0..0000000 Binary files a/extension/img/icon@2x.png and /dev/null differ diff --git a/resources/logo-amo.svg b/extension/img/logo.svg similarity index 96% rename from resources/logo-amo.svg rename to extension/img/logo.svg index eb39056..4f5d3c9 100644 --- a/resources/logo-amo.svg +++ b/extension/img/logo.svg @@ -14,8 +14,8 @@ viewBox="0 0 512 512" id="svg2" version="1.1" - inkscape:version="0.91 r13725" - sodipodi:docname="logo-amo.svg" + inkscape:version="0.92.2 5c3e80d, 2017-08-06" + sodipodi:docname="logo.svg" inkscape:export-filename="/home/icaroperseo/Documentos/Proyectos/Add-ons/BehindTheOverlayRevival/resources/bor.png" inkscape:export-xdpi="90" inkscape:export-ydpi="90"> @@ -47,7 +47,7 @@ borderopacity="1.0" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:zoom="0.49902717" + inkscape:zoom="1.0760273" inkscape:cx="-59.803635" inkscape:cy="290.97192" inkscape:document-units="px" @@ -55,7 +55,7 @@ showgrid="false" units="px" inkscape:window-width="1366" - inkscape:window-height="715" + inkscape:window-height="699" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" /> @@ -67,7 +67,7 @@ image/svg+xml - + diff --git a/extension/js/background.js b/extension/js/background.js index 85f43d7..76ea026 100644 --- a/extension/js/background.js +++ b/extension/js/background.js @@ -1,7 +1,20 @@ -// Get the translated string for context menu. -const contextMenuRemoveOverlayTitle = browser.i18n.getMessage( - 'contextMenuRemoveOverlayTitle'); +let expression = /(http(s?)):\/\//gi; +let regex = new RegExp(expression); +let gettingAllTabs = browser.tabs.query({}); +// Returns true only if the URL's protocol is in APPLICABLE_PROTOCOLS. +function protocolIsApplicable(url) { + return url.match(regex); +} + +// Initialize the page action. Only operates on tabs whose URL's protocol is applicable. +function initializePageAction(tab) { + if (protocolIsApplicable(tab.url)) { + browser.pageAction.show(tab.id); + } +} + +// Main script. function removeOverlay() { // No tabs or host permissions needed! browser.tabs.executeScript(null, {file: '/js/overlay_remover.js'}, @@ -11,18 +24,16 @@ function removeOverlay() { }); } -// Create all the context menu items. -browser.contextMenus.create({ - id: 'removeOverlay', - title: contextMenuRemoveOverlayTitle +// When first loaded, initialize the page action for all tabs. +gettingAllTabs.then((tabs) => { + for (let tab of tabs) { + initializePageAction(tab); + } }); -// The click event listener, where we perform the appropriate action given the -// ID of the menu item that was clicked. -browser.contextMenus.onClicked.addListener(function(info) { - if (info.menuItemId === 'removeOverlay') { - removeOverlay(); - } +// Each time a tab is updated, reset the page action for that tab. +browser.tabs.onUpdated.addListener((id, changeInfo, tab) => { + initializePageAction(tab); }); // Shortcut listener. @@ -32,5 +43,5 @@ browser.commands.onCommand.addListener(function(command) { } }); -// Called when the user clicks on the browser action. -browser.browserAction.onClicked.addListener(removeOverlay); +// Called when the user clicks on the page action. +browser.pageAction.onClicked.addListener(removeOverlay); diff --git a/extension/js/overlay_remover.js b/extension/js/overlay_remover.js index f1bc7c2..6288611 100644 --- a/extension/js/overlay_remover.js +++ b/extension/js/overlay_remover.js @@ -6,6 +6,7 @@ */ const debug = false; +let alertMessage = browser.i18n.getMessage('noOverlayAlertMessage'); let utils = (function() { function hideElement(element) { @@ -164,7 +165,7 @@ let overlayRemover = function(debug, utils) { let first = i === 0; if (candidate === false) { if (first) - alert('No overlay has been found on this website.'); + alert(alertMessage); break; } else { if (!first) { diff --git a/extension/manifest.json b/extension/manifest.json index 34fe183..7a3ba66 100644 --- a/extension/manifest.json +++ b/extension/manifest.json @@ -1,16 +1,20 @@ { + "author": "Iván Ruvalcaba", "background": { "scripts": ["js/background.js", "js/overlay_remover.js"] }, - "browser_action": { + "page_action": { + "browser_style": true, "default_icon": { - "16": "img/icon-16.png", - "19": "img/icon-19.png", - "38": "img/icon-38.png", - "48": "img/icon.png", - "96": "img/icon@2x.png" + "16": "img/close.svg", + "19": "img/close.svg", + "32": "img/close.svg", + "38": "img/close.svg", + "48": "img/close.svg", + "64": "img/close.svg", + "96": "img/close.svg" }, - "default_title": "__MSG_defaultBrowserActionTitle__" + "default_title": "__MSG_defaultPageActionTitle__" }, "commands": { "removeOverlay": { @@ -22,24 +26,22 @@ }, "default_locale": "en", "description": "__MSG_extensionDescription__", - "developer": { - "name": "Icaro Perseo", - "url": "https://icaroperseo.github.io/" - }, - "homepage_url": "https://github.com/icaroperseo/BehindTheOverlayRevival", + "homepage_url": "https://github.com/ivanruvalcaba/BehindTheOverlayRevival", "icons": { - "16": "img/icon-16.png", - "19": "img/icon-19.png", - "38": "img/icon-38.png", - "48": "img/icon.png", - "96": "img/icon@2x.png" + "16": "img/logo.svg", + "19": "img/logo.svg", + "32": "img/logo.svg", + "38": "img/logo.svg", + "48": "img/logo.svg", + "64": "img/logo.svg", + "96": "img/logo.svg" }, "manifest_version": 2, "name": "Behind The Overlay Revival", "permissions": [ "activeTab", - "contextMenus" + "tabs" ], "short_name": "BOR", - "version": "0.1.7" + "version": "0.1.8" } diff --git a/resources/bor-demo.gif b/resources/bor-demo.gif deleted file mode 100644 index 506fb74..0000000 Binary files a/resources/bor-demo.gif and /dev/null differ diff --git a/scripts/prepare_icons.sh b/scripts/prepare_icons.sh deleted file mode 100755 index 840cad9..0000000 --- a/scripts/prepare_icons.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -rsvg-convert -w 16 -h 16 ../design/logo.svg -o ../extension/img/icon-16.png -rsvg-convert -w 19 -h 19 ../design/logo.svg -o ../extension/img/icon-19.png -rsvg-convert -w 38 -h 38 ../design/logo.svg -o ../extension/img/icon-38.png -rsvg-convert -w 48 -h 48 ../design/logo.svg -o ../extension/img/icon.png -rsvg-convert -w 96 -h 96 ../design/logo.svg -o ../extension/img/icon@2x.png -rsvg-convert -w 512 -h 512 ../design/logo.svg -o ../design/logo.png \ No newline at end of file