Simplify QuickStatements Import Buttons

Simplify the import buttons of QuickStatements into one button

目前為 2021-10-27 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Simplify QuickStatements Import Buttons
// @namespace    https://greasyfork.org/users/21515
// @version      0.1.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://www.google.com/s2/favicons?sz=64&domain=quickstatements.toolforge.org
// @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]");
    button_v1.innerText = button_v1.innerText.replace("V1 ","");
    var button_csv = document.querySelector(".btn[tt=dialog_import_csv]");
    if (button_v1 && button_csv && button_v1.onmousedown==null){
        button_v1.onmousedown = function(){
            if (buttonClicks == 0){
                button_csv.click();
            }
        };
        button_csv.style.display="none";
        unsafeWindow.alert = function (str) {
            if (str == "No valid commands found"){
                buttonClicks++;
                if (buttonClicks == 2){
                    alert("No valid commands found");
                }
            }
        };
    }else{
        buttonClicks = 0;
    }
},50);