Advertisement
kamome-sg

Vivaldi ページタイトル・URLコピー用コマンドチェイン

Nov 16th, 2023
1,069
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* forVivaldi コマンドチェインレシピ 1.現在のタブでリンクを開く(コマンドパラメータはこれ) 2.ページにフォーカス */
  2.  
  3. javascript:
  4. var text = document.title + "\n" + location.href;
  5. if(navigator.clipboard) {
  6.     setTimeout(() => (navigator.clipboard.writeText(text).then(() => {}, () => {alert("コピーに失敗しました")})), 100);
  7. }
  8. else {
  9.     var textarea = document.createElement("textarea");
  10.     textarea.value = text;
  11.     document.body.appendChild(textarea);
  12.     textarea.select();
  13.     document.execCommand("copy");
  14.     document.body.removeChild(textarea);
  15. }
  16. if(history.replaceState){history.replaceState({},null,location.href);};
Advertisement
Comments
  • kamome-sg
    1 year
    Comment was deleted
  • kamome-sg
    1 year
    1. /* 改良(?)圧縮版 */
    2. javascript:(t=>{new Promise(r=>setTimeout(r,100)).then(async()=>{await navigator.clipboard.writeText(t)}).catch(()=>{(a=>{a.value=t;document.body.appendChild(a);a.select();document.execCommand('copy');a.remove()})(document.createElement('textarea'))});history.replaceState&&history.replaceState({},'',location.href)})(document.title+'\n'+location.href)
Add Comment
Please, Sign In to add comment
Advertisement