AGSV-Delete-Assistant

AGSV Delete

目前為 2024-11-06 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         AGSV-Delete-Assistant
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  AGSV Delete
// @author       7oomy
// @match        *://*.agsvpt.com/details.php?id=*
// @match        *://*.agsvpt.com/edit.php?id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=agsvpt.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    var delete_reason = "应求"; // 删种原因
    var right_distance = "6%"; // 按钮拒右侧距离

    if (window.location.href.includes("details.php")) {
        // 添加删除按钮
        let deleteButton = document.createElement('button');
        deleteButton.innerHTML = '删除';
        deleteButton.style.position = "fixed";
        deleteButton.style.width = "70px";
        deleteButton.style.height = "30px";
        deleteButton.style.background = "rgb(218, 230, 242)";
        deleteButton.style.cursor = "pointer";
        deleteButton.style.zIndex = "1";
        deleteButton.style.top = "50%";
        deleteButton.style.right = right_distance;
        deleteButton.style.borderRadius = "8px";
        deleteButton.style.display = "block";
        document.body.appendChild(deleteButton);

        // 删除按钮的点击事件
        deleteButton.addEventListener('click', function() {
            // 获取当前页面的ID参数,跳转到编辑页面
            let urlParams = new URLSearchParams(window.location.search);
            let id = urlParams.get('id');
            let hit = urlParams.get('hit');
            if (id && hit) {
                let editUrl = `https://www.agsvpt.com/edit.php?id=${id}`;

                // 在跳转前设置一个标记,表示是通过删除按钮跳转的
                localStorage.setItem('fromDeleteButton', 'true');

                // 跳转到编辑页面
                window.location.href = editUrl;
            }
        });
    }

    // 检查当前页面是否为编辑页面,如果是则自动填写表单
    if (window.location.href.includes("edit.php")) {
        // 如果是通过删除按钮跳转的,执行自动填写和点击操作
        if (localStorage.getItem('fromDeleteButton') === 'true') {
             // 填写输入框和点击按钮
            console.log("================DOne=====================");
            let inputBox = document.querySelector("#outer > form:nth-child(7) > table > tbody > tr:nth-child(6) > td.rowfollow > input[type=text]")
            console.log(inputBox)
            let submitButton = document.querySelector("#outer > form:nth-child(7) > table > tbody > tr:nth-child(7) > td > input[type=submit]")

            if (inputBox && submitButton) {
                inputBox.value = delete_reason;
                submitButton.click();
            }

            // 操作完成后,清除本地存储的标记
            localStorage.removeItem('fromDeleteButton');
        }
    }
})();