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== // ==UserScript==
// @name NGA优化摸鱼体验插件-自动同步数据 // @name NGA优化摸鱼体验插件-自动同步数据
// @namespace https://github.com/lifegpc/userscript/tree/master/NGA_BBS_plugins/AutoSyncData // @namespace https://github.com/lifegpc/userscript/tree/master/NGA_BBS_plugins/AutoSyncData
// @version 1.0.3 // @version 1.0.4
// @author lifegpc // @author lifegpc
// @description 通过WebDAV自动同步数据 // @description 通过WebDAV自动同步数据
// @license MIT // @license MIT
@@ -295,7 +295,7 @@
...config, ...config,
onload: response => { onload: response => {
this.buttons.forEach(button => button.$el.removeAttr('disabled')) this.buttons.forEach(button => button.$el.removeAttr('disabled'))
if (response.status>=200&&response.status<300) { if (response.status >= 200 && response.status < 300) {
resolve(response) resolve(response)
} else { } else {
if (method == 'GET' && response.status == 404) { if (method == 'GET' && response.status == 404) {

View File

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