mirror of https://github.com/gorhill/uBlock.git
eliminate validation warning on AMO: avoid innerHTML
This commit is contained in:
parent
0f9cd6c8c4
commit
0e078e536d
|
@ -67,12 +67,6 @@ vAPI.download = function(details) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.insertHTML = function(node, html) {
|
||||
node.innerHTML = html;
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.getURL = chrome.runtime.getURL;
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -75,30 +75,6 @@ vAPI.download = function(details) {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.insertHTML = (function() {
|
||||
const parser = Components.classes['@mozilla.org/parserutils;1']
|
||||
.getService(Components.interfaces.nsIParserUtils);
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/845
|
||||
// Apparently dashboard pages execute with `about:blank` principal.
|
||||
|
||||
return function(node, html) {
|
||||
while ( node.firstChild ) {
|
||||
node.removeChild(node.firstChild);
|
||||
}
|
||||
|
||||
node.appendChild(parser.parseFragment(
|
||||
html,
|
||||
parser.SanitizerAllowStyle,
|
||||
false,
|
||||
Services.io.newURI('about:blank', null, null),
|
||||
document.documentElement
|
||||
));
|
||||
};
|
||||
})();
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.getURL = function(path) {
|
||||
return 'chrome://' + location.host + '/content/' + path.replace(/^\/+/, '');
|
||||
};
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
<button id="cloudPush" type="button" title="cloudPush"></button>
|
||||
<span data-i18n="cloudNoData"></span>
|
||||
<button id="cloudPull" type="button" title="cloudPull" disabled></button>
|
||||
<button id="cloudPullAndMerge" type="button" title="cloudPullAndMerge" disabled></button>
|
||||
<span id="cloudCog" class="fa"></span>
|
||||
<div id="cloudOptions">
|
||||
<div>
|
||||
<p><label data-i18n="cloudDeviceNamePrompt"></label> <input id="cloudDeviceName" type="text" value="">
|
||||
<p><button id="cloudOptionsSubmit" type="button" data-i18n="genericSubmit"></button>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,6 +1,7 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title></title>
|
||||
<link rel="stylesheet" href="css/common.css" type="text/css">
|
||||
<style>
|
||||
|
|
|
@ -182,21 +182,21 @@ var onInitialize = function(options) {
|
|||
|
||||
fetchCloudData();
|
||||
|
||||
var html = [
|
||||
'<button id="cloudPush" type="button" title="cloudPush"></button>',
|
||||
'<span data-i18n="cloudNoData"></span>',
|
||||
'<button id="cloudPull" type="button" title="cloudPull" disabled></button> ',
|
||||
'<button id="cloudPullAndMerge" type="button" title="cloudPullAndMerge" disabled></button>',
|
||||
'<span id="cloudCog" class="fa"></span>',
|
||||
'<div id="cloudOptions">',
|
||||
' <div>',
|
||||
' <p><label data-i18n="cloudDeviceNamePrompt"></label> <input id="cloudDeviceName" type="text" value="">',
|
||||
' <p><button id="cloudOptionsSubmit" type="button" data-i18n="genericSubmit"></button>',
|
||||
' </div>',
|
||||
'</div>',
|
||||
].join('');
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', 'cloud-ui.html', true);
|
||||
xhr.overrideMimeType('text/html;charset=utf-8');
|
||||
xhr.responseType = 'text';
|
||||
xhr.onload = function() {
|
||||
this.onload = null;
|
||||
var parser = new DOMParser(),
|
||||
parsed = parser.parseFromString(this.responseText, 'text/html'),
|
||||
fromParent = parsed.body;
|
||||
while ( fromParent.firstElementChild !== null ) {
|
||||
widget.appendChild(
|
||||
document.adoptNode(fromParent.firstElementChild)
|
||||
);
|
||||
}
|
||||
|
||||
vAPI.insertHTML(widget, html);
|
||||
vAPI.i18n.render(widget);
|
||||
widget.classList.remove('hide');
|
||||
|
||||
|
@ -207,6 +207,8 @@ var onInitialize = function(options) {
|
|||
uDom('#cloudOptions').on('click', closeOptions);
|
||||
uDom('#cloudOptionsSubmit').on('click', submitOptions);
|
||||
};
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
messaging.send('cloudWidget', { what: 'cloudGetOptions' }, onInitialize);
|
||||
|
||||
|
|
Loading…
Reference in New Issue