Update script.user.js
This commit is contained in:
parent
63607abda0
commit
28e6f30a6a
1 changed files with 13 additions and 8 deletions
|
@ -19,6 +19,8 @@ if(!GM) {
|
|||
return;
|
||||
}
|
||||
|
||||
var instance = "https://git.incest.world";
|
||||
|
||||
async function api(url, data) {
|
||||
var token = await GM.getValue("token");
|
||||
|
||||
|
@ -30,7 +32,7 @@ async function api(url, data) {
|
|||
return new Promise((resolve, reject) => {
|
||||
GM.xmlHttpRequest({
|
||||
method: "POST",
|
||||
url: `https://git.incest.world/api/v1/${url}`,
|
||||
url: `${instance}/api/v1/${url}`,
|
||||
data: JSON.stringify(data),
|
||||
headers: {
|
||||
"Accept": "application/json",
|
||||
|
@ -74,9 +76,11 @@ async function api(url, data) {
|
|||
newButton.onclick = async () => {
|
||||
newButton.disabled = true;
|
||||
|
||||
var repo = location.pathname.split("/")[2];
|
||||
|
||||
var data = await api("repos/migrate", {
|
||||
"clone_addr": location.href,
|
||||
"repo_name": location.pathname.split("/")[2],
|
||||
"clone_addr": document.querySelector("meta[name=go-import]").content.split(" ").slice(-1)[0],
|
||||
"repo_name": repo,
|
||||
"mirror": true,
|
||||
"repo_owner": "mirrors",
|
||||
"description": "Mirror of " + location.href,
|
||||
|
@ -86,12 +90,13 @@ async function api(url, data) {
|
|||
});
|
||||
|
||||
var resp = JSON.parse(data.response);
|
||||
if(resp.message)
|
||||
alert(resp.message);
|
||||
else
|
||||
if(resp.message) {
|
||||
if(resp.message == "The repository with the same name already exists.") {
|
||||
window.open(`${instance}/mirrors/${repo}`);
|
||||
} else alert(resp.message);
|
||||
} else {
|
||||
window.open(resp.html_url);
|
||||
|
||||
newButton.disabled = false;
|
||||
}
|
||||
};
|
||||
|
||||
mirrorButton.innerHTML = "";
|
||||
|
|
Loading…
Add table
Reference in a new issue