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