-
Notifications
You must be signed in to change notification settings - Fork 0
/
qrcode-bookmarklet-src.js
45 lines (40 loc) · 1.25 KB
/
qrcode-bookmarklet-src.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
; (function() {
var qriousUrl = 'https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.min.js';
var id = 'qrious-script-id__' + qriousUrl.replace(/[^\w]|\./g, '_');
var $body = document.getElementsByTagName('body')[0];
if (!window.QRious) {
var $qriousScript = document.createElement('script');
$qriousScript.setAttribute('src', qriousUrl);
$qriousScript.setAttribute('id', id);
$qriousScript.addEventListener('load', generate);
$body.appendChild($qriousScript);
} else {
generate();
}
function generate() {
var $canvas = document.createElement('canvas');
$canvas.addEventListener('click', function() {
$canvas.parentNode.removeChild($canvas);
});
$canvas.setAttribute('title', 'Click to close');
$canvas.setAttribute('style', [
'position: fixed;',
'right: 2vw;',
'top: 2vh;',
'height: 500px;',
'width: 500px;',
'box-shadow: -9px 15px 6px 3px rgba(0, 0, 0, 0.51);',
'z-index: 9999999;',
'padding: 1vw;',
'background: #2c62b8;',
'border-radius: 1rem;',
'cursor: pointer;'
].join(''));
new QRious({
element: $canvas,
value: window.location.href,
size: 500,
});
$body.appendChild($canvas);
}
})();