pwn.college Copy to Clipboard and copy SSH key

this script will allow you to copy the content from the pwn.collage and scopy the ssh key to connect your terminal to the machine

  1. // ==UserScript==
  2. // @license JazzMedo
  3. // @name pwn.college Copy to Clipboard and copy SSH key
  4. // @version 1.0.1
  5. // @description this script will allow you to copy the content from the pwn.collage and scopy the ssh key to connect your terminal to the machine
  6. // @author JazzMedo
  7. // @match https://pwn.college/*
  8. // @include https://pwn.college/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=pwn.college
  10. // @grant none
  11. // @namespace https://greasyfork.org/users/1420266
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. // Select all elements with data-sentry-component="AccordionDetails"
  17. const accordionDetailsList = document.querySelectorAll('.embed-responsive');
  18.  
  19. accordionDetailsList.forEach(detail => {
  20. // Create the copy button
  21. const copyButton = document.createElement('button');
  22. copyButton.innerHTML = `
  23. <svg width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
  24. <path d="M3.5 0a.5.5 0 0 1 .5.5V1h9V.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5V2h-1V1h-9v1H3V.5a.5.5 0 0 1 .5-.5zM1 2h14a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zm0 1v11h14V3H1z"/>
  25. </svg>
  26. `;
  27. copyButton.classList.add('copy-button');
  28.  
  29. // Inject CSS into the document
  30. const style = document.createElement('style');
  31. style.innerHTML = `
  32. .embed-responsive p {
  33. padding-right:28px;
  34. }
  35.  
  36. .copy-button {
  37. position: absolute;
  38. top: 0px;
  39. right: 0px;
  40. background-color: #4CAF50;
  41. border: none;
  42. color: white;
  43. border-radius: 5px;
  44. cursor: pointer;
  45. transition: all 1.5s;
  46. }
  47.  
  48. .copy-button:hover {
  49. background-color: #45a049;
  50. /* Darker green on hover */
  51. }
  52.  
  53. .copy-button:active {
  54. /* Slightly shrink the button on click */
  55. }
  56. .copy-button:focus {
  57. border:none;
  58. /* Slightly shrink the button on click */
  59. outline:none;
  60. }
  61. /* Added a class to change the icon */
  62. .copy-button.copying {
  63. background-color: #0084ff;
  64. content: url('data:image/svg+xml;utf8,<svg width="16" height="16" fill="currentColor" class="bi bi-check" viewBox="0 0 16 16"><path d="M13.485 1.343a1 1 0 0 1 1.415 1.415l-9 9a1 1 0 0 1-1.415 0l-4-4a1 1 0 0 1 1.415-1.415L5.5 10.086l8.485-8.485z" /></svg>');
  65. }
  66.  
  67. `;
  68. document.head.appendChild(style);
  69.  
  70.  
  71. // Add click event to copy text content and change icon
  72. copyButton.addEventListener('click', () => {
  73. navigator.clipboard.writeText(detail.textContent.trim());
  74. copyButton.classList.add('copying');
  75. copyButton.innerHTML = `
  76. <svg width="16" height="16" fill="currentColor" class="bi bi-check" viewBox="0 0 16 16">
  77. <path d="M13.485 1.343a1 1 0 0 1 1.415 1.415l-9 9a1 1 0 0 1-1.415 0l-4-4a1 1 0 0 1 1.415-1.415L5.5 10.086l8.485-8.485z" />
  78. </svg>`;
  79. setTimeout(() => {
  80. copyButton.classList.remove('copying');
  81. copyButton.innerHTML = `
  82. <svg width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
  83. <path d="M3.5 0a.5.5 0 0 1 .5.5V1h9V.5a.5.5 0 0 1 .5-.5h1a.5.5 0 0 1 .5.5V2h-1V1h-9v1H3V.5a.5.5 0 0 1 .5-.5zM1 2h14a1 1 0 0 1 1 1v11a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zm0 1v11h14V3H1z"/>
  84. </svg>`;
  85. }, 1500);
  86. });
  87.  
  88. // Append the button to the detail element
  89. detail.appendChild(copyButton);
  90. });
  91.  
  92. // Create the SSH copy button
  93. const sshCopyButton = document.createElement('button');
  94. sshCopyButton.innerHTML = 'Copy SSH';
  95. sshCopyButton.classList.add('ssh-copy-button');
  96.  
  97. // Inject CSS for the SSH button
  98. const sshButtonStyle = document.createElement('style');
  99. sshButtonStyle.innerHTML = `
  100. .ssh-copy-button {
  101. position: fixed;
  102. bottom: 20px;
  103. left: 20px;
  104. background-color: #007BFF;
  105. border: none;
  106. color: white;
  107. border-radius: 5px;
  108. cursor: pointer;
  109. padding: 5px;
  110. transition: all 0.3s ease-in-out;
  111. font-size:13px;
  112. }
  113.  
  114. .ssh-copy-button:hover {
  115. background-color: #0056b3;
  116. }
  117.  
  118. .ssh-copy-button:active,.ssh-copy-button:focus {
  119. outline:none;
  120. }
  121. `;
  122. document.head.appendChild(sshButtonStyle);
  123.  
  124. // Add click event to copy SSH command
  125. sshCopyButton.addEventListener('click', () => {
  126. navigator.clipboard.writeText('ssh -i key hacker@pwn.college');
  127. sshCopyButton.innerHTML = `Copied`;
  128. sshCopyButton.style.cssText = `background-color: #45a049;`
  129. setTimeout(() => {
  130. sshCopyButton.style.cssText = `background-color: #007BFF;`
  131. sshCopyButton.innerHTML = 'Copy SSH';
  132. }, 1500);
  133. });
  134.  
  135. // Append the SSH button to the body
  136. document.body.appendChild(sshCopyButton);
  137.  
  138.  
  139. })();