-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnotion-tools-block-module.js
48 lines (42 loc) · 1.18 KB
/
notion-tools-block-module.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
46
47
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
function copylink() {
var copyText = document.getElementById('output_link');
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
}
function apply_theme() {
let theme = getParameterByName('t');
if (theme != "black") {
$("body").addClass("white");
} else {
$("body").addClass("black");
}
}
var our_url;
if (window.location != window.parent.location) {
out_url = document.referrer
} else {
out_url = document.location.href
}
if (!out_url) {
out_url = document.location.ancestorOrigins[0]
}
$.ajax({
url: 'https://api2.notion-tools.com/v1/embed',
data: {
in: document.location.href,
out: out_url
},
type: "POST",
dataType: "json"
}).done(json => {
console.log(json)
}).fail((xhr, status, errorThrown) => {
console.log(`Server connect fail ${status} ${errorThrown}`)
} )