AutoSyncData: Format and sync code

This commit is contained in:
2024-08-12 10:58:00 +08:00
committed by GitHub
parent e386990611
commit e97597f640
2 changed files with 4 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name NGA优化摸鱼体验插件-自动同步数据
// @namespace https://github.com/lifegpc/userscript/tree/master/NGA_BBS_plugins/AutoSyncData
// @version 1.0.3
// @version 1.0.4
// @author lifegpc
// @description 通过WebDAV自动同步数据
// @license MIT
@@ -305,12 +305,6 @@
url[url.length - 1] !== '/' && (url += '/')
const username = this.pluginInputs['username'].val().trim()
const password = this.pluginInputs['password'].val().trim()
const methodDict = {
PROPFIND: 207,
GET: 200,
PUT: 201,
DELETE: 204
}
this.buttons.forEach(button => button.$el.attr('disabled', true))
return new Promise((resolve, reject) => {
GM_xmlhttpRequest({
@@ -324,7 +318,7 @@
...config
}).then(response => {
this.buttons.forEach(button => button.$el.removeAttr('disabled'))
if (response.status === methodDict[method]) {
if (response.status >= 200 && response.status < 300) {
resolve(response)
} else {
if (method == 'GET' && response.status == 404) {