-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.user.js
46 lines (44 loc) · 1.16 KB
/
script.user.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
// ==UserScript==
// @name 记录当前的Tab
// @namespace https://liujiale.me
// @version 0.1.4
// @updateURL https://github.com/nailuoGG/deno-bridge-echo/raw/main/script.user.js
// @downloadURL https://github.com/nailuoGG/deno-bridge-echo/raw/main/script.user.js
// @description Store Latest visited Tab into local HTTP server
// @author nailuoGG
// @connect localhost
// @match https://*/*
// @grant GM_xmlhttpRequest
// @noframes
// ==/UserScript==
(function () {
'use strict';
var oldHref = location.href;
var title = document.title;
function track() {
if (document.hidden) {
return;
}
var requestDetails = {
method: "POST",
url: "http://localhost:8000/v1/echo",
data: JSON.stringify({
url: oldHref,
title: title
}),
headers: {
"Content-Type": "application/json"
},
onload: function (response) {
},
onerror: function (err) {
console.log('报错啦', err)
}
}
GM_xmlhttpRequest(requestDetails);
};
if (document.addEventListener) {
document.addEventListener("visibilitychange", track)
}
track();
})();