Last active
May 29, 2020 06:30
-
-
Save 9sako6/863cea77f7fa6f6e836ff0b6f33807bf to your computer and use it in GitHub Desktop.
[title](url) を自動でクリップボードにコピーするブックマークレット
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.createTemplateTagFirstArg=function(a){return a.raw=a};$jscomp.createTemplateTagFirstArgWithRaw=function(a,b){a.raw=b;return a};function execCopy(a){var b=document.createElement("div"),c=document.createElement("pre");c.style.webkitUserSelect="auto";c.style.userSelect="auto";b.appendChild(c).textContent=a;a=b.style;a.position="fixed";a.right="200%";document.body.appendChild(b);document.getSelection().selectAllChildren(b);a=document.execCommand("copy");document.body.removeChild(b);return a}function showToast(a){var b=document.createElement("style");b.innerText="\n /* The snackbar - position it at the top and in the middle of the screen */\n #snackbar {\n visibility: hidden; /* Hidden by default. Visible on click */\n min-width: 250px; /* Set a default minimum width */\n margin-left: -125px; /* Divide value of min-width by 2 */\n background-color: #333; /* Black background color */\n color: #fff; /* White text color */\n text-align: center; /* Centered text */\n border-radius: 2px; /* Rounded borders */\n padding: 16px; /* Padding */\n position: fixed; /* Sit on top of the screen */\n z-index: 1; /* Add a z-index if needed */\n left: 50%; /* Center the snackbar */\n top: 30px; /* 30px from the top */\n }\n\n /* Show the snackbar when clicking on a button (class added with JavaScript) */\n #snackbar.show {\n visibility: visible; /* Show the snackbar */\n /* Add animation: Take 0.5 seconds to fade in and out the snackbar.\n However, delay the fade out process for 2.5 seconds */\n -webkit-animation: fadein 0.5s, fadeout 0.5s 2.5s;\n animation: fadein 0.5s, fadeout 0.5s 2.5s;\n }\n\n /* Animations to fade the snackbar in and out */\n @-webkit-keyframes fadein {\n from {top: 0; opacity: 0;}\n to {top: 30px; opacity: 1;}\n }\n\n @keyframes fadein {\n from {top: 0; opacity: 0;}\n to {top: 30px; opacity: 1;}\n }\n\n @-webkit-keyframes fadeout {\n from {top: 30px; opacity: 1;}\n to {top: 0; opacity: 0;}\n }\n\n @keyframes fadeout {\n from {top: 30px; opacity: 1;}\n to {top: 0; opacity: 0;}\n }\n ";document.body.appendChild(b);var c=document.createElement("div");c.id="snackbar";c.innerText=a;document.body.appendChild(c);c.className="show";setTimeout(function(){document.body.removeChild(c);document.body.removeChild(b)},3E3)}(function(){var a="["+document.title.replace(/`/g,"")+"]("+location.href+")";execCopy(a);showToast("Copied!")})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment