-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdm5_auto_save.user.js
44 lines (39 loc) · 1.06 KB
/
dm5_auto_save.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
// ==UserScript==
// @name DM5 Auto Bookmark
// @version 0.2
// @author Shiaupiau (https://github.com/stu43005)
// @include http://*.dm5.com/*
// @include https://*.dm5.com/*
// @grant none
// ==/UserScript==
(function init(func) {
setTimeout(function () {
if (typeof jQuery === 'undefined') {
console.log('[DM5 Auto Bookmark] No jQuery, try again later');
init(func);
return;
}
const script = document.createElement('script');
script.textContent = '(' + func.toString() + ')(window)';
document.body.appendChild(script);
}, 500);
})(function () {
'use strict';
const data = {
cid: DM5_CID,
mid: DM5_MID,
page: DM5_PAGE,
uid: DM5_USERID,
language: 1,
};
console.log(data);
const formData = new FormData();
Object.keys(data).forEach(k => {
formData.append(k, data[k]);
});
function sendBookmark() {
navigator.sendBeacon('bookmarker.ashx?d=' + new Date().getTime(), formData);
}
jQuery(document).on('click', '#last-win .view-btn-back', sendBookmark);
jQuery(window).on('unload', sendBookmark);
});