Guest User

Untitled

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | None | 0 0
  1. javascript: (function () {
  2.  
  3. window.copyToClipboard = function (text, bannerDelay, dontCopy, noFeedback) {
  4. window.tempBanner = document.createElement("textarea");
  5. var delay;
  6. if (window.tempBannerDelay) {
  7. delay = window.tempBannerDelay;
  8. } else {
  9. delay = bannerDelay ? bannerDelay : 3000;
  10. }
  11. tempBanner.setAttribute("style", "position:absolute;top:0%;left:0%;color:white;background-color:black;padding:0.4%; z-index:9999;width:99.8%;height:250px;font-family:monospace;font-weight:bold");
  12. tempBanner.value = text;
  13. document.body.appendChild(tempBanner);
  14. tempBanner.select();
  15. if (dontCopy) {
  16. tempBanner.value = text;
  17. if (noFeedback) {
  18. tempBanner.remove();
  19. console.log(text);
  20. } else {
  21. setTimeout(function () {
  22. tempBanner.remove();
  23. }, delay);
  24. }
  25. } else {
  26. if (document.execCommand('copy')) {
  27. var newText = '-------- Copied to clipboard --------\n\n\n\n' + text;
  28. tempBanner.value = newText;
  29. if (noFeedback) {
  30. tempBanner.remove();
  31. console.log(newText);
  32. } else {
  33. setTimeout(function () {
  34. tempBanner.remove();
  35. }, delay);
  36. }
  37. } else {
  38. var err = '!!!!!!!! Could not copy to clipboard !!!!!!!!\n\n\n\n' + text;
  39. tempBanner.value = err;
  40. if (noFeedback) {
  41. tempBanner.remove();
  42. console.log(err);
  43. } else {
  44. setTimeout(function () {
  45. tempBanner.remove();
  46. }, delay);
  47. }
  48. }
  49. }
  50. };
  51.  
  52. var cqString = localStorage.getItem('cq');
  53. if (cqString == undefined) {
  54. alert('No CQ data object present in localStorage for:' + location.origin);
  55. } else {
  56. var cqObject = JSON.parse(cqString);
  57. if (Object.keys(cqObject).length) {
  58. var title = 'Delete ' + Object.keys(cqObject).length + ' objects from localStorage??\n';
  59. var msg = title + '\n';
  60. for (var key in cqObject) {
  61. msg += key + '\n';
  62. }
  63. var cnfm = confirm(msg);
  64. if (cnfm) {
  65. delete localStorage.cq;
  66. alert('Cleared CQ data object (' + Object.keys(cqObject).length + ' keys) from localstorage for:' + location.origin);
  67. } else {
  68.  
  69. }
  70. copyToClipboard(msg);
  71. } else {
  72. delete localStorage.cq;
  73. alert('Cleared empty CQ data object from localstorage for:' + location.origin);
  74. }
  75. }
  76.  
  77. })();
Add Comment
Please, Sign In to add comment