FF bug workaround: retranslate CSS content
This commit is contained in:
parent
2e86c95842
commit
2687d1e167
12
dom.js
12
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)) + '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
manage.js
11
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);
|
||||
|
||||
|
|
15
popup.js
15
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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user