Update script.user.js

This commit is contained in:
Lilith Ashley Nyx Arson 🔥 2024-10-21 16:34:44 +00:00
parent 63607abda0
commit 28e6f30a6a

View file

@ -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 = "";