Input Copier

just cick on input!

  1. // ==UserScript==
  2. // @namespace http://tampermonkey.net/
  3. // @name Input Copier
  4. // @version 1.2.1
  5. // @description just cick on input!
  6. // @author SuperJava
  7. // @match http://codeforces.com/*/*/*/*
  8. // ==/UserScript==
  9.  
  10. function copyToClipboard(text) {
  11. if (window.clipboardData && window.clipboardData.setData) {
  12. return clipboardData.setData("Text", text);
  13. } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
  14. var textarea = document.createElement("textarea");
  15. textarea.textContent = text;
  16. textarea.style.position = "fixed";
  17. document.body.appendChild(textarea);
  18. textarea.select();
  19. try {
  20. return document.execCommand("copy");
  21. } catch (ex) {
  22. console.warn("Copy to clipboard failed.", ex);
  23. return false;
  24. } finally {
  25. document.body.removeChild(textarea);
  26. }
  27. }
  28. }
  29.  
  30.  
  31. var x = document.getElementsByClassName("sample-test")[0].getElementsByClassName("title");
  32. var i;
  33. for (i = 0; i < x.length; i++) {
  34. x[i].onclick = function(event){myFunction(event);};
  35. }
  36.  
  37. function myFunction(event) {
  38. var eea = event.currentTarget;
  39. var testx = eea.parentElement.getElementsByTagName("PRE")[0];
  40. var nsq = testx.innerHTML.replace(/<br>/gi,"\n");
  41. copyToClipboard(nsq);
  42. eea.style.backgroundColor = "red";
  43. setTimeout(function() {
  44. eea.style.backgroundColor = "white";
  45. }, 1000);
  46. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址