diff --git a/dom.js b/dom.js index 30d21779..b1443562 100644 --- a/dom.js +++ b/dom.js @@ -123,3 +123,15 @@ function $element(opt) { } return element; } + + +function retranslateCSS(selectorToMessageMap) { + // TODO: remove when this bug is fixed in FF + // Note: selectors must be spec-normalized e.g. ::before, not :before + for (const rule of document.styleSheets[0].cssRules) { + const msg = selectorToMessageMap[rule.selectorText]; + if (msg) { + rule.style.content = '"' + msg.replace(/__MSG_(\w+)__/g, (_, id) => t(id)) + '"'; + } + } +} diff --git a/manage.js b/manage.js index c5485367..61829014 100644 --- a/manage.js +++ b/manage.js @@ -1,4 +1,4 @@ -/* global messageBox, getStyleWithNoCode */ +/* global messageBox, getStyleWithNoCode, retranslateCSS */ 'use strict'; let installed; @@ -31,6 +31,15 @@ Promise.all([ showStyles(styles); }); +if (FIREFOX) { + // TODO: remove when this bug is fixed in FF + retranslateCSS({ + '.disabled h2::after': + '__MSG_genericDisabledLabel__', + '#update-all-no-updates[data-skipped-edited="true"]::after': + ' __MSG_updateAllCheckSucceededSomeEdited__', + }); +} chrome.runtime.onMessage.addListener(onRuntimeMessage); diff --git a/popup.js b/popup.js index fde184bf..1e951533 100644 --- a/popup.js +++ b/popup.js @@ -1,3 +1,4 @@ +/* global retranslateCSS */ 'use strict'; let installed; @@ -16,6 +17,20 @@ getActiveTabRealURL().then(url => { }); }); +if (FIREFOX) { + // TODO: remove when this bug is fixed in FF + retranslateCSS({ + '.blocked::before': + '__MSG_stylusUnavailableForURL__', + '.blocked #installed::before': + '__MSG_stylusUnavailableForURLdetails__', + '.unreachable::before': + '__MSG_unreachableContentScript__', + '.unreachable #installed::before': + '__MSG_unreachableFileHint__', + }); +} + chrome.runtime.onMessage.addListener(onRuntimeMessage); function onRuntimeMessage(msg) {