Vimm: Download Button

Ajoute un bouton Download sur les page Nintendo

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Vimm: Download Button
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Ajoute un bouton Download sur les page Nintendo
// @author       Ares
// @match        https://vimm.net/vault/*
// @grant        none
// @run-at       document-end
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Fonction pour ajouter le bouton s'il n'existe pas
    function addSubmitButton(form) {
        // Vérifie si un élément de type submit existe dans le formulaire
        const submitButton = form.querySelector('button[type="submit"], input[type="submit"]');
        if (!submitButton) {
            // Créer un nouveau bouton
            const newButton = document.createElement("button");
            newButton.type = "submit";
            newButton.style.width = "100%";
            newButton.textContent = "Download";

            // Ajouter le bouton au formulaire (par exemple, à la fin)
            form.appendChild(newButton);
            console.log("Bouton 'Download' ajouté au formulaire:", form);
        } else {
            console.log("Le formulaire contient déjà un bouton de type submit:", form);
        }
    }

    // Sélectionne tous les formulaires ayant l'id "dl_form"
    const forms = document.querySelectorAll('form#dl_form');
    if (forms.length > 0) {
        forms.forEach(form => addSubmitButton(form));
    } else {
        console.log("Aucun formulaire avec l'id 'dl_form' trouvé sur cette page.");
    }
})();