Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript: (function () {
- window.copyToClipboard = function (text, bannerDelay, dontCopy, noFeedback) {
- window.tempBanner = document.createElement("textarea");
- var delay;
- if (window.tempBannerDelay) {
- delay = window.tempBannerDelay;
- } else {
- delay = bannerDelay ? bannerDelay : 3000;
- }
- 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");
- tempBanner.value = text;
- document.body.appendChild(tempBanner);
- tempBanner.select();
- if (dontCopy) {
- tempBanner.value = text;
- if (noFeedback) {
- tempBanner.remove();
- console.log(text);
- } else {
- setTimeout(function () {
- tempBanner.remove();
- }, delay);
- }
- } else {
- if (document.execCommand('copy')) {
- var newText = '-------- Copied to clipboard --------\n\n\n\n' + text;
- tempBanner.value = newText;
- if (noFeedback) {
- tempBanner.remove();
- console.log(newText);
- } else {
- setTimeout(function () {
- tempBanner.remove();
- }, delay);
- }
- } else {
- var err = '!!!!!!!! Could not copy to clipboard !!!!!!!!\n\n\n\n' + text;
- tempBanner.value = err;
- if (noFeedback) {
- tempBanner.remove();
- console.log(err);
- } else {
- setTimeout(function () {
- tempBanner.remove();
- }, delay);
- }
- }
- }
- };
- var cqString = localStorage.getItem('cq');
- if (cqString == undefined) {
- alert('No CQ data object present in localStorage for:' + location.origin);
- } else {
- var cqObject = JSON.parse(cqString);
- if (Object.keys(cqObject).length) {
- var title = 'Delete ' + Object.keys(cqObject).length + ' objects from localStorage??\n';
- var msg = title + '\n';
- for (var key in cqObject) {
- msg += key + '\n';
- }
- var cnfm = confirm(msg);
- if (cnfm) {
- delete localStorage.cq;
- alert('Cleared CQ data object (' + Object.keys(cqObject).length + ' keys) from localstorage for:' + location.origin);
- } else {
- }
- copyToClipboard(msg);
- } else {
- delete localStorage.cq;
- alert('Cleared empty CQ data object from localstorage for:' + location.origin);
- }
- }
- })();
Add Comment
Please, Sign In to add comment