From f699b96dd8f1b81c6bd8faa435cf15f92174a1c3 Mon Sep 17 00:00:00 2001 From: "a.magail" Date: Mon, 5 Oct 2020 13:38:23 +0200 Subject: [PATCH] EXT-166-Firefox --- _locales/fr/messages.json | 6 ++--- html/background.html | 1 + lib/qwant.js | 48 +++++++++++++-------------------------- manifest.json | 12 ++++------ 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/_locales/fr/messages.json b/_locales/fr/messages.json index 142fabb..3294d7f 100644 --- a/_locales/fr/messages.json +++ b/_locales/fr/messages.json @@ -3,11 +3,9 @@ "message" : "fr_fr" }, "name" : { - "message" : "Qwant", - "description" : "Nom de l'extension" + "message" : "Qwant" }, "description" : { - "message" : "L'extension Qwant définit qwant.com comme votre moteur de recherche et page d'accueil par défaut.", - "description" : "Description de l'extension" + "message" : "L'extension Qwant définit qwant.com comme votre moteur de recherche et page d'accueil par défaut." } } diff --git a/html/background.html b/html/background.html index 9805e17..abbdcdb 100644 --- a/html/background.html +++ b/html/background.html @@ -4,6 +4,7 @@ + diff --git a/lib/qwant.js b/lib/qwant.js index 66e32e2..d717dbc 100644 --- a/lib/qwant.js +++ b/lib/qwant.js @@ -1,38 +1,22 @@ "use strict"; -var manifest = browser.runtime.getManifest(); +var manifest = chrome.runtime.getManifest(); +var browser = chrome; -browser.webRequest.onBeforeRequest.addListener(function(details) { - if (!details.url.match(/webext=true/)) { - return { - redirectUrl: details.url.replace('client=brz-moz', 'client=ext-firefox') + '&webext=' + manifest.version - }; - } - - return {}; -}, { - urls: ["https://www.qwant.com/?*client=brz-moz*q=*", "https://www.qwant.com/?*q=*client=brz-moz*"], - types: ["main_frame"] -}, ["blocking"]); +chrome.runtime.onInstalled.addListener(function (details) { -browser.runtime.setUninstallURL('https://www.qwant.com/extension/feedback?v=' + manifest.version); - -browser.contextMenus.create({ - title : 'Search Qwant for "%s"', - contexts: ["selection"], - onclick : function (info) { - var queryText = info.selectionText; - browser.tabs.create({ - url: "https://www.qwant.com/?q=" + queryText + "&client=ext-firefox-cm" - }); + if (details.reason === "install") { + chrome.tabs.query({active: true}, (tabsArray) => { + if (tabsArray.length > 0 && tabsArray[0].hasOwnProperty('url') && tabsArray[0].url.match(/^https:\/\/www.qwant\.com.*/) !== null) { + chrome.tabs.executeScript({ + code: "document.querySelector('.extension__chrome__overlay__instructions').style.display = 'none';document.querySelector('.extension__overlay__thanks').style.display = 'block';" + }); + } + chrome.tabs.create({ + url: "https://www.qwant.com/extension/thanks", + active: false + }); + }) } }); -browser.runtime.onMessage.addListener((message, sender, callback) => { - switch (message.name) { - case 'uninstall': - browser.management.uninstallSelf({ - showConfirmDialog: true - }).then(null, null); - break; - } -}); \ No newline at end of file +chrome.runtime.setUninstallURL('https://www.qwant.com/extension/feedback?v=' + manifest.version); diff --git a/manifest.json b/manifest.json index 463a5dd..433cc4b 100644 --- a/manifest.json +++ b/manifest.json @@ -9,6 +9,11 @@ "48": "img/icon48.png", "128": "img/icon128.png" }, + "browser_action": { + "browser_style": true, + "default_icon": "img/icon48.png", + "default_title": "__MSG_name__" + }, "background": { "page": "html/background.html" }, @@ -23,14 +28,7 @@ "is_default": true } }, - "omnibox": { - "keyword": "q" - }, "permissions": [ - "contextMenus", - "tabs", - "webRequest", - "webRequestBlocking", "https://*.qwant.com/*" ], "content_scripts": [