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;
|
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) {
|
vAPI.getURL = function(path) {
|
||||||
return 'chrome://' + location.host + '/content/' + path.replace(/^\/+/, '');
|
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>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
<title></title>
|
<title></title>
|
||||||
<link rel="stylesheet" href="css/common.css" type="text/css">
|
<link rel="stylesheet" href="css/common.css" type="text/css">
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -182,21 +182,21 @@ var onInitialize = function(options) {
|
||||||
|
|
||||||
fetchCloudData();
|
fetchCloudData();
|
||||||
|
|
||||||
var html = [
|
var xhr = new XMLHttpRequest();
|
||||||
'<button id="cloudPush" type="button" title="cloudPush"></button>',
|
xhr.open('GET', 'cloud-ui.html', true);
|
||||||
'<span data-i18n="cloudNoData"></span>',
|
xhr.overrideMimeType('text/html;charset=utf-8');
|
||||||
'<button id="cloudPull" type="button" title="cloudPull" disabled></button> ',
|
xhr.responseType = 'text';
|
||||||
'<button id="cloudPullAndMerge" type="button" title="cloudPullAndMerge" disabled></button>',
|
xhr.onload = function() {
|
||||||
'<span id="cloudCog" class="fa"></span>',
|
this.onload = null;
|
||||||
'<div id="cloudOptions">',
|
var parser = new DOMParser(),
|
||||||
' <div>',
|
parsed = parser.parseFromString(this.responseText, 'text/html'),
|
||||||
' <p><label data-i18n="cloudDeviceNamePrompt"></label> <input id="cloudDeviceName" type="text" value="">',
|
fromParent = parsed.body;
|
||||||
' <p><button id="cloudOptionsSubmit" type="button" data-i18n="genericSubmit"></button>',
|
while ( fromParent.firstElementChild !== null ) {
|
||||||
' </div>',
|
widget.appendChild(
|
||||||
'</div>',
|
document.adoptNode(fromParent.firstElementChild)
|
||||||
].join('');
|
);
|
||||||
|
}
|
||||||
|
|
||||||
vAPI.insertHTML(widget, html);
|
|
||||||
vAPI.i18n.render(widget);
|
vAPI.i18n.render(widget);
|
||||||
widget.classList.remove('hide');
|
widget.classList.remove('hide');
|
||||||
|
|
||||||
|
@ -207,6 +207,8 @@ var onInitialize = function(options) {
|
||||||
uDom('#cloudOptions').on('click', closeOptions);
|
uDom('#cloudOptions').on('click', closeOptions);
|
||||||
uDom('#cloudOptionsSubmit').on('click', submitOptions);
|
uDom('#cloudOptionsSubmit').on('click', submitOptions);
|
||||||
};
|
};
|
||||||
|
xhr.send();
|
||||||
|
};
|
||||||
|
|
||||||
messaging.send('cloudWidget', { what: 'cloudGetOptions' }, onInitialize);
|
messaging.send('cloudWidget', { what: 'cloudGetOptions' }, onInitialize);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue