Simplify QuickStatements Import Buttons

Simplify the import buttons of QuickStatements into one button

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Simplify QuickStatements Import Buttons
// @namespace    https://greasyfork.org/users/21515
// @version      0.2.0
// @description  Simplify the import buttons of QuickStatements into one button
// @author       CennoxX
// @contact      [email protected]
// @homepage     https://github.com/CennoxX/userscripts
// @supportURL   https://github.com/CennoxX/userscripts/issues/new?title=[Simplify%20QuickStatements%20Import%20Buttons]%20
// @match        https://quickstatements.toolforge.org/*
// @icon         https://quickstatements.toolforge.org/favicon.ico
// @grant        unsafeWindow
// @run-at       document-start
// @license      MIT
// ==/UserScript==
/* jshint esversion: 8 */
/* eslint curly: "off" */
var buttonClicks = 0;
setInterval(()=>{
    var button_v1 = document.querySelector(".btn[tt=dialog_import_v1]");
    var button_csv = document.querySelector(".btn[tt=dialog_import_csv]");
    var button_all = document.querySelector("button:nth-child(3)");
    if (button_v1 && button_csv && !button_all){
        document.addEventListener("keydown", function (e) {
            if (e.ctrlKey && (event.keyCode == 10 || event.keyCode == 13)){
                button_csv.click();
                button_v1.click();
            }
        }, false);
        button_all = button_v1.cloneNode();
        button_all.attributes.removeNamedItem("tt");
        button_all.innerHTML = "Anweisungen importieren";
        button_all.onmousedown = function(){
            button_csv.click();
            button_v1.click();
        };
        button_v1.parentNode.append(button_all);
        button_v1.style.display = "none";
        button_csv.style.display = "none";
        unsafeWindow.alert = function (str) {
            if (str == "No valid commands found"){
                setTimeout(()=>{
                    buttonClicks++;
                    if (buttonClicks % 2 == 0 && document.querySelector("textarea")){
                        alert("No valid commands found");
                    }
                }, 100);
            }
        };
    }
},100);