generated at
タイトルとURLのコピーをするブックマークレット
タイトルとURLのコピーをするブックマークレット

これまでchromeの拡張機能Copy Title and Url as Markdown Style - Chrome ウェブストアを使っていたが、微妙に反応が遅かった

ブックマークレットでも同じ機能が実現できて、とても軽くて便利

タイトルとURLのコピーをするブックマークレット 2022-02-21
javascript:(()=>{const e=()=>{const e=document.createElement("div"),c=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/ /g,"&nbsp;").replace(/\n/g,"<br>");e.innerHTML=c(n());const t=document.getElementsByTagName("body")[0];t.appendChild(e);const o=document.createRange();o.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(o);const l=document.execCommand("copy");t.removeChild(e),console.log("Copy successful? = "+l)},n=()=>{let e=document.title,n=document.URL;const c={":":":","\\[":"[","\\]":"]","\\|":"|"};for(let n in c)e=e.replace(new RegExp(n,"g"),c[n]);return e+"\n"+n+"\n\n"};e()})();

タイトルとURLのコピーしてscrapboxのリンク記法に整形するブックマークレット 2022-02-21
javascript:(()=>{const e=()=>{const e=document.createElement("div"),c=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/ /g,"&nbsp;").replace(/\n/g,"<br>");e.innerHTML=c(n());const t=document.getElementsByTagName("body")[0];t.appendChild(e);const o=document.createRange();o.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(o);const l=document.execCommand("copy");t.removeChild(e),console.log("Copy successful? = "+l)},n=()=>{let e=document.title,n=document.URL;const c={":":":","\\[":"[","\\]":"]","\\|":"|"};for(let n in c)e=e.replace(new RegExp(n,"g"),c[n]);return "["+e+" "+n+"]"};e()})();


ーーーー
旧版
タイトルとURLのコピーをするブックマークレット2021-03-27
javascript:var global=window;global.COPY_TO_CLIPBOARD=global.COPY_TO_CLIPBOARD||{};global.COPY_TO_CLIPBOARD.getUrlInfo=function(){var a=new String(document.title);a.allReplace=function(a){var b=this,c;for(c in a)b=b.replace(new RegExp(c,"g"),a[c]);return b}.bind(a);return a.allReplace({":":"\uff1a","\\[":"\uff3b","\\]":"\uff3d"})+"\n"+document.URL};global.COPY_TO_CLIPBOARD.copyToClipboard=function(){var a=document.createElement("textarea");a.textContent=this.getUrlInfo();var d=document.getElementsByTagName("body")[0];d.appendChild(a);a.select();var b=document.execCommand("copy");d.removeChild(a);return b};global.COPY_TO_CLIPBOARD.copyToClipboard();

タイトルとURLのコピーしてscrapboxのリンク記法に整形するブックマークレット2021-03-27
javascript:var global=window;global.COPY_TO_CLIPBOARD=global.COPY_TO_CLIPBOARD||{};global.COPY_TO_CLIPBOARD.getUrlInfo=function(){var a=new String(document.title);a.allReplace=function(a){var b=this,c;for(c in a)b=b.replace(new RegExp(c,"g"),a[c]);return b}.bind(a);return "["+a.allReplace({":":"\uff1a","\\[":"\uff3b","\\]":"\uff3d"})+" "+document.URL+"]"};global.COPY_TO_CLIPBOARD.copyToClipboard=function(){var a=document.createElement("textarea");a.textContent=this.getUrlInfo();var d=document.getElementsByTagName("body")[0];d.appendChild(a);a.select();var b=document.execCommand("copy");d.removeChild(a);return b};global.COPY_TO_CLIPBOARD.copyToClipboard();



WebページのタイトルとURLをワンクリックでコピーするBookmarklet - Qiita
>
>



2022/02/13
TwitterでタイトルとURLのコピーをするブックマークレットが動作しない
他のページでは問題なく動作する

Qiitaで質問してみた
>WebページのタイトルとURLをワンクリックでコピーするBookmarklet - Qiita


とりあえずこの方法でなんとかなるので,scrapboxを使う場合はこれでいく
>ScrapboxでURL貼り付けたらページタイトルでリンク化される機能がなくなったと思ったら,Ctrl+Shift+Vでできるんですね.裏技っぽくて良い.ちなみにtwitterのツイートだとツイート内容も埋め込めてすばらしい.

以下の方法の方がいい感じ
→chromeの拡張機能で問題なさそうCopy Title and Url as Markdown Style - Chrome ウェブストア
結局これで対応している

これも試してみたい
>PC版Chromeのアドレスバーにある「このページを共有」→「共有するリンク」→「Twitter」の動作が欲しかった機能に近い
>今までブックマーク追加ボタンでページタイトルをコピー・アドレスバー右クリックでURLコピーして貼り付けてたけど、これならツイート欄で半角スペースを改行に置き換えで済む

2022/02/22 Twitterで動作しないのを修正対応頂いた
>
不具合の報告だけでも貢献できることが嬉しい感覚がある
プルリクエスト的な感覚,コミュニティへの貢献の面白さを感じられた


ただし,googlepodcastで動作しなくなっている...
googledriveでも動作しない
google系と相性が悪そう

spotifyでも動作しない
ーーーー
#023 NARUTOへの愛を語ろう第二弾(後編) - 重箱の隅 Season2 | Spotify でポッドキャスト


2022/03/07
開いているWebページのタイトルとURLをクリップボードにコピーするブックマークレット(+ダイアログ版) - 晴歩雨描

ブックマークレット
javascript:(()=>{
const e=()=>{
const e=document.createElement("div"),
c=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/ /g,"&nbsp;").replace(/\n/g,"<br>");e.innerHTML=c(n());const t=document.getElementsByTagName("body")0;t.appendChild(e);const o=document.createRange();o.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(o);const
l=document.execCommand("copy");t.removeChild(e),console.log("Copy successful? = "+l)},
n=()=>{let e=document.title,n=document.URL;const c={":":":","\\":"[","\\":"]","\\|":"|"};for(let n in c)e=e.replace(new RegExp(n,"g"),cn);return e+"\n"+n+"\n\n"};e()})();

javascript:(function(){var now=new Date();window.open("https://scrapbox.io/taiseidou/ネタ置き場(思考の貯水湖)"+"?body="+encodeURIComponent("["+document.title+" "+window.location.href+"]\n"+window.getSelection().toString().split(/\n+/g).map(function(line){return line.length>0?%27> %27+line:%27%27}).join(%27\n%27)))}())