Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- javascript:!function(){var e=document.getElementById("clipboardUtilityPanel");e&&e.remove();var t=document.createElement("div");t.id="clipboardUtilityPanel",Object.assign(t.style,{position:"fixed",bottom:"10px",left:"10px",zIndex:"9999",maxWidth:"300px",maxHeight:"80vh",overflowY:"auto",background:"rgba(0, 0, 0, 0.8)",color:"#fff",padding:"10px",borderRadius:"5px",fontFamily:"Arial, sans-serif",fontSize:"14px",display:"block"});var o=document.createElement("div");o.textContent="📋 Clipboard Utility",Object.assign(o.style,{fontWeight:"bold",marginBottom:"8px",padding:"5px",background:"#444",cursor:"grab",textAlign:"center",borderRadius:"5px",position:"relative"}),t.appendChild(o);var n=document.createElement("span");n.textContent="✖",Object.assign(n.style,{cursor:"pointer",position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",fontSize:"16px",padding:"0 5px"}),o.appendChild(n);var a,i,r,l,d=!1;function c(e){d=!0,a=e.clientX,i=e.clientY,r=t.offsetLeft,l=t.offsetTop,o.style.cursor="grabbing"}function p(e){if(d){var o=e.clientX-a,n=e.clientY-i;t.style.left=r+o+"px",t.style.top=l+n+"px",t.style.bottom="auto"}}function s(){d=!1,o.style.cursor="grab"}o.addEventListener("mousedown",c),document.addEventListener("mousemove",p),document.addEventListener("mouseup",s),n.addEventListener("click",(function(){o.removeEventListener("mousedown",c),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",s),t.remove()}));var x='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>';[{text:"Clear Clipboard",id:"clearClipboard"},{text:"Log Clipboard Content",id:"logClipboard"},{text:"Plaintext → HTML Clipboard",id:"copyToHtml"},{text:"Plaintext ← HTML Clipboard",id:"copyToPlain"},{text:"Show Clipboard MIME Types",id:"toggleClipboard",isToggle:!0}].forEach((function(e){var o=document.createElement("button");if(o.id=e.id,Object.assign(o.style,{width:"100%",margin:"4px 0",padding:"6px",border:"none",borderRadius:"3px",cursor:"pointer",backgroundColor:"#444",color:"#fff",fontSize:"14px",fontFamily:"Arial, sans-serif"}),e.isToggle){o.style.position="relative",o.style.textAlign="center";var n=document.createElement("span");n.className="btn-text",n.textContent=e.text,o.appendChild(n);var a=document.createElement("span");a.className="btn-icon",a.innerHTML=x,Object.assign(a.style,{position:"absolute",right:"10px",top:"50%",transform:"translateY(-50%)"}),o.appendChild(a)}else o.textContent=e.text;t.appendChild(o)}));var m=document.createElement("div");m.style.display="block",t.appendChild(m),document.body.appendChild(t);var b="";async function y(){m.innerHTML="";try{var e=await navigator.clipboard.read();if(0===e.length)return void(m.textContent="Clipboard is empty or unreadable.");for(var t of e)for(var o of t.types){var n=await t.getType(o),a=document.createElement("div");a.textContent="MIME Type: "+o+" ("+(((l=n.size)<1024?l+" B":l<1048576?(l/1024).toFixed(2)+" KB":l<1073741824?(l/1048576).toFixed(2)+" MB":(l/1073741824).toFixed(2)+" GB")+")"),a.style.fontWeight="bold",a.style.marginTop="8px",m.appendChild(a);var i=o.startsWith("image/")?"<Binary data; "+n.size+" bytes>":await n.text(),r=document.createElement("pre");Object.assign(r.style,{whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"120px",overflowY:"auto",background:"#222",color:"#0f0",padding:"5px"}),r.textContent=i,m.appendChild(r)}}catch(e){m.textContent="Error: Clipboard read failed - "+e}var l}function g(){var e=document.getElementById("toggleClipboard"),t=e.querySelector(".btn-text"),o=e.querySelector(".btn-icon");"none"===m.style.display?(t.textContent="Show Clipboard MIME Types",o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><line x1="8" y1="3" x2="8" y2="13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/><line x1="3" y1="8" x2="13" y2="8" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'):(t.textContent="Hide Clipboard MIME Types",o.innerHTML=x)}document.getElementById("logClipboard").addEventListener("click",(async function(){try{var e=await navigator.clipboard.read();for(var t of e)for(var o of t.types){var n=await t.getType(o);console.log("MIME Type:",o),console.log("Content:",await n.text())}}catch(e){console.error("Failed to read clipboard contents:",e)}})),document.getElementById("toggleClipboard").addEventListener("click",(function(){m.style.display="none"===m.style.display?"block":"none",g()})),document.getElementById("copyToHtml").addEventListener("click",(async function(){try{var e=await navigator.clipboard.readText();await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([e],{type:"text/plain"}),"text/html":new Blob([e],{type:"text/html"})})]),console.log("Plain text content copied to clipboard as HTML."),y()}catch(e){console.error("Clipboard write (HTML) failed:",e)}})),document.getElementById("copyToPlain").addEventListener("click",(async function(){try{var e=await navigator.clipboard.read();for(var t of e)if(t.types.includes("text/html")){var o=await t.getType("text/html");return await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([await o.text()],{type:"text/plain"})})]),console.log("HTML content copied to clipboard as Plaintext."),void y()}console.error("No HTML content found in the clipboard.")}catch(e){console.error("Clipboard write (Plaintext) failed:",e)}})),document.getElementById("clearClipboard").addEventListener("click",(async function(){try{await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([""],{type:"text/plain"}),"text/html":new Blob([""],{type:"text/html"})})]),console.log("Clipboard cleared."),y()}catch(e){console.error("Clipboard clear failed:",e)}})),setInterval((async function(){if(document.hasFocus())try{var e=await navigator.clipboard.readText();e!==b&&(b=e,y())}catch(e){}}),1e3),g()}();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement