// ==UserScript== // @name Copy for Scrapbox // @namespace http://scrapbox.io/mactkg-pub/ // @version 0.1 // @description Copy URL and title of a page by scrapbox style. Add quote tag to lead of each line when you selected text. // @author mactkg // @match *://*/* // @run-at context-menu // @grant GM_setClipboard // @downloadURL https://scrapbox.io/api/code/mactkg-pub/Scrapbox%E5%BD%A2%E5%BC%8F%E3%81%A7URL%E6%83%85%E5%A0%B1%E3%82%92%E3%82%B3%E3%83%94%E3%83%BC%E3%81%99%E3%82%8BTampermonkey%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%88/copy-as-scrapbox.user.js // ==/UserScript== const getScrapLink = () => { const link = `[${document.title.replace(/\s*[\[\]]\s*/g,' ')} ${location.href}]` let quote = window.getSelection().toString() if(quote.length > 0) { quote = quote.split('\n').map(line => `> ${line}`).join('\n') return `${quote}\n> ${link}` } return link }; (function() { const text = getScrapLink(); GM_setClipboard(text, "text"); })();