skript.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // ==UserScript==
  2. // @name Key card
  3. // @description Innovative and easy password generation
  4. // @version 1.0
  5. // @grant none
  6. // ==/UserScript==
  7. // Configure me!
  8. let spacebar = "test";
  9. let keys = "ijklmnopqrstuvwxyz0123456789abcdefgh".split("");
  10. // Whoa, below this line is the code, change at your own peril
  11. const basic = "abcdefghijklmnopqrstuvwxyz0123456789".split("");
  12. let card = basic.reduce((c, e, i) => {
  13. c[[e]] = keys[i];
  14. return c;
  15. }, {".": ""});
  16. addCSS = (css) => {
  17. var head, obj;
  18. head = document.getElementsByTagName('head')[0];
  19. if (!head) {
  20. return;
  21. }
  22. obj = document.createElement('style');
  23. obj.type = 'text/css';
  24. obj.innerHTML = css;
  25. head.appendChild(obj);
  26. }
  27. addJS = (js) => {
  28. var head, obj;
  29. head = document.getElementsByTagName('head')[0];
  30. if (!head) {
  31. return;
  32. }
  33. obj = document.createElement('script');
  34. obj.type = 'text/javascript';
  35. obj.innerHTML = js;
  36. head.appendChild(obj);
  37. }
  38. let domain = document.domain;
  39. //console.log("Hello " + domain + ", I'm Key card.");
  40. const convert_card = () => {
  41. let out = "[";
  42. for (let k in card) {
  43. let v = card[k];
  44. if (out != "[") {
  45. out += ",";
  46. }
  47. out += "[\"" + k + "\",\"" + v + "\"]";
  48. }
  49. out += "]";
  50. return out;
  51. }
  52. addCSS(`
  53. .keycardmenu{
  54. position:fixed;
  55. top:5px;
  56. left:-450px;
  57. padding: 0.5em 1em;
  58. margin: 2em 0;
  59. width: 400px;
  60. background: #444444CC;
  61. border: solid 5px #00A182FF;
  62. border-radius: 14px;
  63. margin: 10px;
  64. padding: 10px;
  65. line-height: 1.3;
  66. overflow: auto;
  67. text-align: left;
  68. width: 450px;
  69. height: 160px;
  70. transition-duration: 0.5s;
  71. transition-delay: 3s;
  72. z-index: 9999;
  73. }
  74. .keycardmenu:hover{
  75. position:fixed;
  76. top:5px;
  77. left:-10px;
  78. transition-delay: 0s;
  79. }
  80. .keycardh1{
  81. color: white;
  82. font-size: 32px;
  83. }
  84. .keycardtxt{
  85. color: white;
  86. font-size: 14px;
  87. }
  88. .keycardbtn {
  89. background: grey;
  90. color: white;
  91. border: 1px solid black;
  92. }
  93. `);
  94. addJS(`
  95. const card = new Map(${convert_card()});
  96. const spacebar = "${spacebar}";
  97. const copy2Clipboard = (data) => {
  98. navigator.clipboard.writeText(data);
  99. alert("Copied!");
  100. };
  101. const domain_name = "${domain}";
  102. `);
  103. addJS(`
  104. const generate_pass = () => {
  105. let pass = "" + spacebar;
  106. for (let idx in domain_name) {
  107. let c = domain_name.at(idx);
  108. let v = card.get(c.toLowerCase());
  109. if (v) {
  110. pass += v;
  111. }
  112. }
  113. return pass;
  114. };
  115. `);
  116. const my_bod = `
  117. <div class="keycardmenu" oncopy="return false;" onselectstart="return false;" oncontextmenu="return false;">
  118. <h1 class="keycardh1">Key Card</h1>
  119. <p class="keycardtxt">Domain: ${domain}</p>
  120. <button class="keycardbtn" onclick="copy2Clipboard(generate_pass())">Copy Password</button>
  121. </div>
  122. `;
  123. document.body.innerHTML = document.body.innerHTML + my_bod;