-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.js
45 lines (35 loc) · 926 Bytes
/
content.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
document.addEventListener('mouseup', function (event) {
url = formatText(getText());
if (url.length > 95) {
chrome.runtime.sendMessage({
type: "url",
url: url
}, function (response) {
console.log(response.status);
});
}
});
let getText = function () {
var text = "";
if (window.getSelection) {
text = window.getSelection().toString();
}
return text;
}
let formatText = function (text) {
let x = "";
let yBool = false;
let y = "";
for (let i = 0; i < text.length; i++) {
if (!yBool && text[i] != " ") {
x = x + text[i]
}
else {
yBool = true;
if (text[i] != " " || text[i] != ",") {
y = y + text[i];
}
}
}
return `https://mapy.cz/zakladni?x=${y}&y=${x}&z=17&pano=1&source=coor&id=${y}%2C${x}`;
}