try downloadable
Signed-off-by: 283375 <here@283375.xyz>
This commit is contained in:
parent
a9f52a423c
commit
75c60c0789
@ -1,104 +1,105 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Arcaea Offline Get Data Script
|
// @name Arcaea Offline Get Data Script
|
||||||
// @namespace http://tampermonkey.net/
|
// @namespace http://tampermonkey.net/
|
||||||
// @version 0.1
|
// @version 0.1
|
||||||
// @description wow
|
// @description wow
|
||||||
// @author 283375
|
// @author 283375
|
||||||
// @match https://arcaea.lowiro.com/*/profile/*
|
// @match https://arcaea.lowiro.com/*/profile/*
|
||||||
// @icon https://arcaea.lowiro.com/icon/favicon-96x96.png
|
// @icon https://arcaea.lowiro.com/icon/favicon-96x96.png
|
||||||
// @grant none
|
// @grant none
|
||||||
// ==/UserScript==
|
// @downloadURL https://gitea.283375.xyz/283375/arcaea-offline-tampermonkey-scripts/raw/branch/master/get-arcaea-online-data.js
|
||||||
|
// ==/UserScript==
|
||||||
(function() {
|
|
||||||
'use strict';
|
(function() {
|
||||||
|
'use strict';
|
||||||
const req = new XMLHttpRequest()
|
|
||||||
req.addEventListener("load", saveRequest)
|
const req = new XMLHttpRequest()
|
||||||
req.withCredentials = true
|
req.addEventListener("load", saveRequest)
|
||||||
req.open("GET", "https://webapi.lowiro.com/webapi/score/rating/me")
|
req.withCredentials = true
|
||||||
req.send()
|
req.open("GET", "https://webapi.lowiro.com/webapi/score/rating/me")
|
||||||
const req2 = new XMLHttpRequest()
|
req.send()
|
||||||
req2.addEventListener("load", saveRequest)
|
const req2 = new XMLHttpRequest()
|
||||||
req2.withCredentials = true
|
req2.addEventListener("load", saveRequest)
|
||||||
req2.open("GET", "https://webapi.lowiro.com/webapi/user/me")
|
req2.withCredentials = true
|
||||||
req2.send()
|
req2.open("GET", "https://webapi.lowiro.com/webapi/user/me")
|
||||||
|
req2.send()
|
||||||
const style = document.createElement('style')
|
|
||||||
style.innerHTML = `
|
const style = document.createElement('style')
|
||||||
div.arcofl-container {
|
style.innerHTML = `
|
||||||
position: fixed;
|
div.arcofl-container {
|
||||||
left: 50px;
|
position: fixed;
|
||||||
top: 25px;
|
left: 50px;
|
||||||
padding: 1rem 1.5rem;
|
top: 25px;
|
||||||
border-radius: 7.5px;
|
padding: 1rem 1.5rem;
|
||||||
background: linear-gradient(225deg, rgba(39, 166, 229, 0.65), rgba(39, 166, 229, 0.28));
|
border-radius: 7.5px;
|
||||||
display: flex;
|
background: linear-gradient(225deg, rgba(39, 166, 229, 0.65), rgba(39, 166, 229, 0.28));
|
||||||
flex-direction: column;
|
display: flex;
|
||||||
z-index: 5000;
|
flex-direction: column;
|
||||||
}
|
z-index: 5000;
|
||||||
|
}
|
||||||
a.arcofl-download-button {
|
|
||||||
display: block;
|
a.arcofl-download-button {
|
||||||
background-color: #e9e9e9;
|
display: block;
|
||||||
border-radius: 7.5px;
|
background-color: #e9e9e9;
|
||||||
cursor: pointer;
|
border-radius: 7.5px;
|
||||||
margin: 0.5em 0;
|
cursor: pointer;
|
||||||
padding: 0.5em 1em;
|
margin: 0.5em 0;
|
||||||
outline: 2px solid rgba(255, 255, 255, 0);
|
padding: 0.5em 1em;
|
||||||
transition: 0.375s;
|
outline: 2px solid rgba(255, 255, 255, 0);
|
||||||
}
|
transition: 0.375s;
|
||||||
|
}
|
||||||
a.arcofl-download-button:hover {
|
|
||||||
background-color: #f0f0f0;
|
a.arcofl-download-button:hover {
|
||||||
outline: 2px solid #27a6e5;
|
background-color: #f0f0f0;
|
||||||
}
|
outline: 2px solid #27a6e5;
|
||||||
|
}
|
||||||
span.arcofl-download-button-error {
|
|
||||||
display: block;
|
span.arcofl-download-button-error {
|
||||||
background: linear-gradient(125deg, hsl(5deg, 80%, 70%), hsl(5deg, 80%, 50%));
|
display: block;
|
||||||
color: hsl(5deg, 20%, 100%);
|
background: linear-gradient(125deg, hsl(5deg, 80%, 70%), hsl(5deg, 80%, 50%));
|
||||||
border-radius: 7.5px;
|
color: hsl(5deg, 20%, 100%);
|
||||||
margin: 0.5em 0;
|
border-radius: 7.5px;
|
||||||
padding: 0.5em 1em;
|
margin: 0.5em 0;
|
||||||
}
|
padding: 0.5em 1em;
|
||||||
`
|
}
|
||||||
document.head.append(style)
|
`
|
||||||
|
document.head.append(style)
|
||||||
let div = document.createElement('div')
|
|
||||||
div.classList.add('arcofl-container')
|
let div = document.createElement('div')
|
||||||
div.innerText = 'Arcaea Offline'
|
div.classList.add('arcofl-container')
|
||||||
document.body.appendChild(div)
|
div.innerText = 'Arcaea Offline'
|
||||||
|
document.body.appendChild(div)
|
||||||
function saveRequest(e) {
|
|
||||||
if (e.length < e.total) {
|
function saveRequest(e) {
|
||||||
alert('Incomplete request')
|
if (e.length < e.total) {
|
||||||
}
|
alert('Incomplete request')
|
||||||
|
}
|
||||||
const url = this.responseURL
|
|
||||||
const regex = /.*\.lowiro\.com\//gi
|
const url = this.responseURL
|
||||||
const replacedUrl = url.replace(regex, '')
|
const regex = /.*\.lowiro\.com\//gi
|
||||||
const fileName = replacedUrl.replaceAll('/', '_') + '.json'
|
const replacedUrl = url.replace(regex, '')
|
||||||
try {
|
const fileName = replacedUrl.replaceAll('/', '_') + '.json'
|
||||||
const content = this.responseText
|
try {
|
||||||
const contentJson = JSON.parse(content)
|
const content = this.responseText
|
||||||
if (!contentJson.success) throw new Error(`status ${contentJson.error_code}`)
|
const contentJson = JSON.parse(content)
|
||||||
|
if (!contentJson.success) throw new Error(`status ${contentJson.error_code}`)
|
||||||
// https://stackoverflow.com/a/65050772/16484891
|
|
||||||
// CC BY-SA 4.0
|
// https://stackoverflow.com/a/65050772/16484891
|
||||||
const file = new Blob([content], {type: 'text/plain'})
|
// CC BY-SA 4.0
|
||||||
window.URL = window.URL || window.webkitURL
|
const file = new Blob([content], {type: 'text/plain'})
|
||||||
const buttonLink = document.createElement('a')
|
window.URL = window.URL || window.webkitURL
|
||||||
buttonLink.innerText = fileName
|
const buttonLink = document.createElement('a')
|
||||||
buttonLink.setAttribute("href", window.URL.createObjectURL(file))
|
buttonLink.innerText = fileName
|
||||||
buttonLink.setAttribute("download", fileName)
|
buttonLink.setAttribute("href", window.URL.createObjectURL(file))
|
||||||
buttonLink.classList.add('arcofl-download-button')
|
buttonLink.setAttribute("download", fileName)
|
||||||
div.append(buttonLink)
|
buttonLink.classList.add('arcofl-download-button')
|
||||||
} catch (e) {
|
div.append(buttonLink)
|
||||||
const errorSpan = document.createElement('span')
|
} catch (e) {
|
||||||
errorSpan.innerText = `${fileName} ${e}`
|
const errorSpan = document.createElement('span')
|
||||||
errorSpan.classList.add('arcofl-download-button-error')
|
errorSpan.innerText = `${fileName} ${e}`
|
||||||
console.error(fileName, url, e)
|
errorSpan.classList.add('arcofl-download-button-error')
|
||||||
div.append(errorSpan)
|
console.error(fileName, url, e)
|
||||||
}
|
div.append(errorSpan)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})();
|
})();
|
Loading…
x
Reference in New Issue
Block a user