12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- // ==UserScript==
- // @name T-All-历史记录
- // @author tianyunperfect
- // @description 简介
- // @version 1.0.0
- // @update 2021-07-08 16:16:14
- // @match *://*/*
- // @require https://git.tianyunperfect.cn/tianyunperfect/web-base/raw/master/monkey/util.js?a=2022年05月15日
- // @require https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js
- // @require https://cdn.bootcdn.net/ajax/libs/js-cookie/3.0.1/js.cookie.min.js
- // ==/UserScript==
- (async () => {
- if (window.top !== window.self) {
- return;
- }
- function save() {
- if (window.top.location.href == window.location.href) {
- axios.post(`https://web_history.tianyunperfect.cn/history/insert`, {
- "title": document.title,
- "url": location.href,
- "user_id": 1
- }).then(res => {
- console.log(res.data);
- }).catch(function (error) {
- alert(error);
- });
- }
- }
- function getKey() {
- return "t_href_" + location.href;
- }
- function setTitle() {
- Cookies.set(getKey(), document.title);
- }
- function checkTitle() {
- return Cookies.get(getKey()) !== document.title
- }
- setTimeout(() => {
- setTitle();
- save();
- setInterval(() => {
- if (checkTitle()) {
- setTitle();
- save();
- }
- }, 5000)
- }, 5000)
- })();
|