-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlaunch-codever-dialog.js
More file actions
27 lines (25 loc) · 978 Bytes
/
launch-codever-dialog.js
File metadata and controls
27 lines (25 loc) · 978 Bytes
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
{
const l = location.href;
let d = '';
if ( document.getSelection() && document.getSelection().toString().trim() !== '' ) {
d = document.getSelection();
}
const t = document.title;
let w, h;
if ( innerWidth > 1400 ) {
w = 930;
} else {
w = (innerWidth * 65) / 100;
}
if ( innerHeight > 1400 ) {
h = 1150;
} else {
h = (innerHeight * 90) / 100;
}
const features = `toolbar=no,width=${w},height=${h},top=${innerHeight - h}, left=${innerWidth - w}`;
let url = `https://www.codever.dev/my-bookmarks/new?url=${encodeURIComponent(l)}&desc=${encodeURIComponent(d)}&title=${encodeURIComponent(t)}&popup=true&initiator=browser-extension`;
if ( d != '' ) {
url = `https://www.codever.dev/new-entry?url=${encodeURIComponent(l)}&selection=${encodeURIComponent(d)}&title=${encodeURIComponent(t)}&popup=true&initiator=browser-extension`;
}
open(url, 'Codever', features);
}