Skip to content

Commit 66c46ac

Browse files
author
jagdeep sidhu
committed
bind to existing trezor element in html
1 parent ac5f97a commit 66c46ac

File tree

1 file changed

+4
-24
lines changed

1 file changed

+4
-24
lines changed

trezor-usb-permissions.js

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,16 @@
1818
filters: [{ vendorId: 0x534c }, { vendorId: 0x1209 }],
1919
});
2020
setStatus('USB permission granted. You can close this tab/window.');
21-
try {
22-
if (window.opener && document.referrer) {
23-
try {
24-
let url = new URL(document.referrer);
25-
if (url.origin && url.origin !== 'null') {
26-
window.opener.postMessage(
27-
{ type: 'trezor-usb-permission-granted' },
28-
url.origin
29-
);
30-
}
31-
} catch (_) {}
32-
}
33-
} catch (_) {}
3421
} catch (e) {
3522
setStatus(e && e.message ? e.message : 'USB permission error', true);
3623
}
3724
}
3825

3926
// Simple inline UI
4027
window.addEventListener('DOMContentLoaded', function () {
41-
let btn = document.createElement('button');
42-
btn.textContent = 'Grant USB permission';
43-
btn.style.cssText =
44-
'margin:16px;padding:8px 12px;border-radius:9999px;border:0;background:#2563eb;color:#fff;cursor:pointer;';
45-
btn.onclick = requestUsb;
46-
document.body.appendChild(btn);
47-
let p = document.createElement('p');
48-
p.id = 'status';
49-
p.style.cssText =
50-
'font:13px system-ui, sans-serif; color:#475569; margin-left:16px;';
51-
document.body.appendChild(p);
28+
let btn = document.getElementById('grant-btn');
29+
if (btn) {
30+
btn.addEventListener('click', requestUsb);
31+
}
5232
});
5333
})();

0 commit comments

Comments
 (0)