1Password 1-click archive & delete

Adds a 1-Click Delete & Archive Buttons for entries

  1. // ==UserScript==
  2. // @name 1Password 1-click archive & delete
  3. // @namespace http://tampermonkey.net/
  4. // @version 2.0
  5. // @description Adds a 1-Click Delete & Archive Buttons for entries
  6. // @namespace https://greasyfork.org/en/users/807108-jeremy-r
  7. // @author JRem
  8. // @match https://*.1password.com/vaults/*/*/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=1password.com
  10. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  11. // @require https://greasyfork.org/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631
  12. // @grant GM_addStyle
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. // Customizable timeout for re-adding buttons after use
  18. const timeout = "1500";
  19. // Wait for the buttons to be visible before starting
  20. waitForKeyElements (
  21. "#item-details",
  22. addBtn
  23. );
  24. waitForKeyElements (
  25. "#top-bar-notifications",
  26. topBtn
  27. );
  28. // CSS Style to put both of the new buttons on the same line
  29. var css = '.clickarchive {margin-left:3px!important;}';
  30. css += 'div#divdelarc {display: inline-flex !important;margin-left: 0px !important;align-content: center !important;}';
  31. css += '#topdiv {display: inline-flex !important;}';
  32. GM_addStyle(css);
  33.  
  34. function topBtn() {
  35. var tdparent = document.querySelector('div[id="title-container"]');
  36. var topdiv = document.createElement("div");
  37. topdiv.id = "topdiv";
  38.  
  39. tdparent.appendChild(topdiv);
  40.  
  41. var topbtn = document.createElement("button");
  42. topbtn.innerHTML = "Add Buttons";
  43. topbtn.className= "item-detail-button clickadd";
  44. topbtn.id= "clickadd";
  45. topbtn.style.background = "red";
  46. topbtn.onclick= function(){
  47. addBtn();
  48. }
  49. var div1=document.querySelector('div[id="topdiv"]');
  50. div1.appendChild(topbtn);
  51. }
  52.  
  53. // Function to add buttons
  54. function addBtn() {
  55. // Define Delete Button
  56. var delbtn = document.createElement("button");
  57. delbtn.innerHTML = "Delete";
  58. delbtn.className= "item-detail-button clickdelete";
  59. delbtn.id= "clickdelete";
  60. delbtn.style.background = "red";
  61. delbtn.onclick= function(){
  62. document.querySelector('button[data-testid="toolbar-edit"]').click();
  63. document.querySelector('button[data-testid="toolbar-delete"]').click();
  64. document.querySelector('button[id="submit"]').click();
  65. // When the buttons are used, the page gets reloaded, however since its using websocket it cant re-add the buttons without help
  66. // This just tells it to re-add the button 1.5 seconds after it has been clicked.
  67. // If the buttons are not visible after being used, increase the timeout var at the top
  68. setTimeout(function(){
  69. addBtn();
  70. }, timeout);
  71. }
  72. var div = document.querySelector('button[class="item-detail-button"]');
  73.  
  74. // Define new DIV to put buttons in
  75. var newdiv = document.createElement("div");
  76. newdiv.id = "divdelarc";
  77. // Append DIV to page
  78. div.parentElement.appendChild(newdiv);
  79. // Add Delete button
  80. newdiv.appendChild(delbtn);
  81.  
  82. // Define Archive button
  83. var archivebtn = document.createElement("button");
  84. archivebtn.innerHTML = "Archive";
  85. archivebtn.className= "item-detail-button clickarchive";
  86. archivebtn.id= "clickarchive";
  87. archivebtn.style.background = "red";
  88. archivebtn.onclick= function(){
  89. document.querySelector('button[data-testid="toolbar-edit"]').click();
  90. document.querySelector('button[data-testid="toolbar-archive"]').click();
  91. document.querySelector('button[id="archive-selected-item"]').click();
  92. // When the buttons are used, the page gets reloaded, however since its using websocket it cant re-add the buttons without help
  93. // This just tells it to re-add the button 1.5 seconds after it has been clicked.
  94. // If the buttons are not visible after being used, increase the timeout var at the top
  95. setTimeout(function(){
  96. addBtn();
  97. }, timeout);
  98. }
  99. // Add Archive button to page
  100. newdiv.appendChild(archivebtn);
  101. }
  102.  
  103. })();