Simplify QuickStatements Import Buttons

Simplify the import buttons of QuickStatements into one button

  1. // ==UserScript==
  2. // @name Simplify QuickStatements Import Buttons
  3. // @namespace https://greasyfork.org/users/21515
  4. // @version 0.2.0
  5. // @description Simplify the import buttons of QuickStatements into one button
  6. // @author CennoxX
  7. // @contact cesar.bernard@gmx.de
  8. // @homepage https://github.com/CennoxX/userscripts
  9. // @supportURL https://github.com/CennoxX/userscripts/issues/new?title=[Simplify%20QuickStatements%20Import%20Buttons]%20
  10. // @match https://quickstatements.toolforge.org/*
  11. // @icon https://quickstatements.toolforge.org/favicon.ico
  12. // @grant unsafeWindow
  13. // @run-at document-start
  14. // @license MIT
  15. // ==/UserScript==
  16. /* jshint esversion: 8 */
  17. /* eslint curly: "off" */
  18. var buttonClicks = 0;
  19. setInterval(()=>{
  20. var button_v1 = document.querySelector(".btn[tt=dialog_import_v1]");
  21. var button_csv = document.querySelector(".btn[tt=dialog_import_csv]");
  22. var button_all = document.querySelector("button:nth-child(3)");
  23. if (button_v1 && button_csv && !button_all){
  24. document.addEventListener("keydown", function (e) {
  25. if (e.ctrlKey && (event.keyCode == 10 || event.keyCode == 13)){
  26. button_csv.click();
  27. button_v1.click();
  28. }
  29. }, false);
  30. button_all = button_v1.cloneNode();
  31. button_all.attributes.removeNamedItem("tt");
  32. button_all.innerHTML = "Anweisungen importieren";
  33. button_all.onmousedown = function(){
  34. button_csv.click();
  35. button_v1.click();
  36. };
  37. button_v1.parentNode.append(button_all);
  38. button_v1.style.display = "none";
  39. button_csv.style.display = "none";
  40. unsafeWindow.alert = function (str) {
  41. if (str == "No valid commands found"){
  42. setTimeout(()=>{
  43. buttonClicks++;
  44. if (buttonClicks % 2 == 0 && document.querySelector("textarea")){
  45. alert("No valid commands found");
  46. }
  47. }, 100);
  48. }
  49. };
  50. }
  51. },100);