32 lines
1.1 KiB
JavaScript
32 lines
1.1 KiB
JavaScript
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
exports["default"] = void 0;
|
|
|
|
var render = function render(className, url) {
|
|
var query = className || '.trezor-webusb-button';
|
|
var buttons = document.querySelectorAll(query);
|
|
var src = url + "?" + Date.now();
|
|
buttons.forEach(function (b) {
|
|
if (b.getElementsByTagName('iframe').length < 1) {
|
|
var bounds = b.getBoundingClientRect();
|
|
var btnIframe = document.createElement('iframe');
|
|
btnIframe.frameBorder = '0';
|
|
btnIframe.width = Math.round(bounds.width) + "px";
|
|
btnIframe.height = Math.round(bounds.height) + "px";
|
|
btnIframe.style.position = 'absolute';
|
|
btnIframe.style.top = '0px';
|
|
btnIframe.style.left = '0px';
|
|
btnIframe.style.zIndex = '1'; // btnIframe.style.opacity = '0'; // this makes click impossible on cross-origin
|
|
|
|
btnIframe.setAttribute('allow', 'usb');
|
|
btnIframe.setAttribute('scrolling', 'no');
|
|
btnIframe.src = src; // inject iframe into button
|
|
|
|
b.append(btnIframe);
|
|
}
|
|
});
|
|
};
|
|
|
|
var _default = render;
|
|
exports["default"] = _default; |