LoginSignup
2
5

More than 5 years have passed since last update.

ページのURLをいい感じにクリップボードにコピーするブックマークレット

Posted at

Rust programming language | https://www.rust-lang.org/ こんな感じでコピーできます。
形式はお好きな形にどうぞ。

javascript:(()=>{var d=document,b=d.body,c=d.createElement.bind(d),t=c("p"),p=c('p');p.style.userSelect='auto';t.appendChild(p).textContent=d.title+" | "+location.href;b.appendChild(t);d.getSelection().selectAllChildren(t);d.execCommand("copy");b.removeChild(t)})()

minify 前

var tmp = document.createElement('p');
var pre = document.createElement('p');
pre.style.userSelect = 'auto';
tmp.appendChild(pre).textContent = document.title + ' | ' + location.href;
document.body.appendChild(tmp);
document.getSelection().selectAllChildren(tmp);
document.execCommand('copy');

参考: JavaScriptでクリップボードに文字をコピーする(ブラウザ) - Qiita

2
5
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
5