Merge branch 'master' of https://github.com/RockinChaos/miru into pr-test

This commit is contained in:
NoCrypt 2024-09-10 19:49:46 +07:00
commit ba5f58ebe6
2 changed files with 31 additions and 3 deletions

25
CONTRIBUTING.md Normal file
View file

@ -0,0 +1,25 @@
```
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
```

View file

@ -4,7 +4,7 @@ import IPC from '@/modules/ipc.js'
import { toast } from 'svelte-sonner'
import Debug from 'debug'
const debug = Debug('ui:anilist')
const debug = Debug('ui:settings')
export let profiles = writable(JSON.parse(localStorage.getItem('profiles')) || [])
/** @type {{viewer: import('./al').Query<{Viewer: import('./al').Viewer}>, token: string} | null} */
@ -60,12 +60,15 @@ window.addEventListener('paste', ({ clipboardData }) => {
handleToken(token)
}
} else if (text.includes("code=") && text.includes("&state")) { // is a MyAnimeList authorization
let code = line.split('code=')[1].split('&state')[0]
let state = line.split('&state=')[1]
let code = text.split('code=')[1].split('&state')[0]
let state = text.split('&state=')[1]
if (code && state) {
if (code.endsWith('/')) code = code.slice(0, -1)
if (state.endsWith('/')) state = state.slice(0, -1)
if (state.includes('%')) state = decodeURIComponent(state)
// remove linefeed characters from the state
code = code.replace(/(\r\n|\n|\r)/gm, '')
state = state.replace(/(\r\n|\n|\r)/gm, '')
handleMalToken(code, state)
}
}