skript.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 card = {".": "", "a": "b", "b": "a", "c": "d", "d": "c", "e": "f", "f": "e", "g": "h", "h": "g", "i": "j", "j": "i", "l": "m", "m": "l", "n": "o", "o": "n", "p": "q", "q": "p", "r": "s", "s": "r", "t": "u", "u": "t", "v": "y", "y": "v", "x": "z", "z": "x", "0": "1", "1": "0", "2": "3", "3": "2", "4": "5", "5": "4", "6": "7", "7": "6", "8": "9", "9": "8"};
  9. let spacebar = "test";
  10. // Rest of the User script
  11. addCSS = (css) => {
  12. var head, obj;
  13. head = document.getElementsByTagName('head')[0];
  14. if (!head) {
  15. return;
  16. }
  17. obj = document.createElement('style');
  18. obj.type = 'text/css';
  19. obj.innerHTML = css;
  20. head.appendChild(obj);
  21. }
  22. addJS = (js) => {
  23. var head, obj;
  24. head = document.getElementsByTagName('head')[0];
  25. if (!head) {
  26. return;
  27. }
  28. obj = document.createElement('script');
  29. obj.type = 'text/javascript';
  30. obj.innerHTML = js;
  31. head.appendChild(obj);
  32. }
  33. let domain = document.domain;
  34. //console.log("Hello " + domain + ", I'm Key card.");
  35. addCSS(`
  36. .keycardmenu{
  37. position:absolute;
  38. top:55px;
  39. left:-450px;
  40. padding: 0.5em 1em;
  41. margin: 2em 0;
  42. width: 400px;
  43. background: #444444AA;
  44. border: solid 5px #00A182FF;
  45. border-radius: 14px;
  46. margin: 10px;
  47. padding: 10px;
  48. line-height: 1.3;
  49. overflow: auto;
  50. text-align: left;
  51. width: 450px;
  52. height: 130px;
  53. transition-duration: 0.5s;
  54. }
  55. .keycardmenu:hover{
  56. position:absolute;
  57. left:-20px;
  58. }
  59. `);
  60. addJS(`
  61. const card = new Map(${convert_card()});
  62. const spacebar = "${spacebar}";
  63. const copy2Clipboard = (data) => {
  64. navigator.clipboard.writeText(data);
  65. alert("Copied!");
  66. };
  67. const domain_name = "${domain}";
  68. `);
  69. addJS(`
  70. const generate_pass = () => {
  71. let pass = "" + spacebar;
  72. for (let idx in domain_name) {
  73. let c = domain_name.at(idx);
  74. let v = card.get(c.toLowerCase());
  75. if (v) {
  76. pass += v;
  77. }
  78. }
  79. return pass;
  80. };
  81. `);
  82. const my_bod = `
  83. <div class="keycardmenu" oncopy="return false;" onselectstart="return false;" oncontextmenu="return false;">
  84. <h1>Key Card</h1><br>
  85. <p>Domain: ${domain}</p>
  86. <button onclick="copy2Clipboard(generate_pass())">Copy Password</button>
  87. </div>
  88. `;
  89. document.body.innerHTML = my_bod + document.body.innerHTML;