diff --git a/source/background.js b/source/background.js index b1e13d7..81a6b04 100644 --- a/source/background.js +++ b/source/background.js @@ -1,3 +1,4 @@ +import 'webext-dynamic-content-scripts' import localforage from 'localforage' import { isEmpty } from './libs/utils' import { renderBadge } from './libs/browser' diff --git a/source/content.css b/source/content.css index 2f8d8eb..553a6f1 100644 --- a/source/content.css +++ b/source/content.css @@ -30,10 +30,13 @@ color: #edb200 !important; } +/* close button */ .qui-possede-les-medias-button { + cursor: pointer; background: none !important; color: white !important; border: none !important; - float: right !important; + float: left !important; margin: -1.5em !important; + font-size: 1em; } diff --git a/source/content.js b/source/content.js index 05f3b8c..882342c 100644 --- a/source/content.js +++ b/source/content.js @@ -1,4 +1,3 @@ -import 'webext-dynamic-content-scripts' import select from 'select-dom' import elementReady from 'element-ready' @@ -27,7 +26,7 @@ async function init () { const button = document.createElement('button') button.className = 'qui-possede-les-medias-button' - button.innerHTML = '✖' + button.innerHTML = '×' button.addEventListener('click', (e) => e.currentTarget.parentNode.remove()) box.appendChild(button) diff --git a/source/libs/browser.js b/source/libs/browser.js index 7fd3d9e..a710d3a 100644 --- a/source/libs/browser.js +++ b/source/libs/browser.js @@ -18,7 +18,7 @@ export const queryPermission = async (permission) => { export const requestPermission = async (permission) => { try { - return browser.permissions.request({permissions: [permission]}) + return browser.permissions.request({origins: [permission]}) } catch (error) { console.log(error) return false diff --git a/source/libs/utils.js b/source/libs/utils.js index 9491554..8021673 100644 --- a/source/libs/utils.js +++ b/source/libs/utils.js @@ -1,11 +1,6 @@ export const isEmpty = variable => (!variable || variable.length === 0 || Object.getOwnPropertyNames(variable).length === 0) -export const renderData = (data) => [ - renderPlural(data.filter(entity => entity.type === 'group'), 'du groupe', 'des groupes'), - renderPlural(data.filter(entity => entity.type === 'holder'), 'appartient à', 'appartient à'), -].join(' ') - -export const renderPlural = (data, preSingular, prePlural) => { +export const renderPlural = (data) => { if (data.length < 1) { return null } @@ -14,14 +9,14 @@ export const renderPlural = (data, preSingular, prePlural) => { : entity.name ) if (data.length === 1) { - return `${preSingular} ${data.pop()}` + return data.pop() } if (typeof Intl !== 'undefined' && Intl.ListFormat) { const lf = new Intl.ListFormat('fr') - return `${prePlural} ${lf.format(data)}` + return lf.format(data) } const last = data.pop() - return prePlural + ' ' + [ + return [ data.join(', '), last ].join(' et ') @@ -30,6 +25,6 @@ export const renderPlural = (data, preSingular, prePlural) => { export const renderText = (data) => { const text = document.createElement('p') text.className = 'qui-possede-les-medias-text' - text.innerHTML = `Ce média ${renderData(data)}.` + text.innerHTML = `Ce média appartient à ${renderPlural(data)}.` return text }