Skip to content

Instantly share code, notes, and snippets.

@ohtomi
Last active May 8, 2019 14:37
Show Gist options
  • Save ohtomi/ccbd32d1e82fcb68d20f3a22171d9b0b to your computer and use it in GitHub Desktop.
Save ohtomi/ccbd32d1e82fcb68d20f3a22171d9b0b to your computer and use it in GitHub Desktop.
Scrapboxのブックマークレット例
javascript:(function(){var title=window.prompt('Scrap "Scrapbox" to ohtomi.',document.title);
if (!title) return;
if (window.location.href.startsWith('https://github.com') && title.indexOf(':')!==-1) title=title.substr(0,title.indexOf(':'));
var lines=[];
if (window.location.href.startsWith('https://github.com')) lines.push('[https://assets-cdn.github.com/images/modules/open_graph/github-mark.png]');
else if (window.location.href.startsWith('http://stackoverflow.com')) lines.push('[https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-logo.png]');
else if (window.location.href.startsWith('http://qiita.com')) lines.push('[https://cdn.qiita.com/assets/qiita-fb-2887e7b4aad86fd8c25cea84846f2236.png]');
else if (window.location.href.startsWith('http://www.slideshare.net/')) lines.push('[http://public.slidesharecdn.com/b/images/logo/linkedin-ss/SS_Logo_Black_Large.png]');
else if (window.location.href.startsWith('https://speakerdeck.com')) lines.push('[http://www.cytoscape.org/images/icon/SpeakerDeck128.png]');
lines.push(window.location.href);
var quote=window.getSelection().toString();
if (quote.trim()) lines=lines.concat(quote.split(/\n/g).map(function(line){return ' > '+line}));
lines.push('');
if (window.location.href.startsWith('https://github.com')) lines.push('#Repo');
else if (window.location.href.startsWith('http://stackoverflow.com')) lines.push('#StackOverflow #Bookmark');
else if (window.location.href.startsWith('http://qiita.com')) lines.push('#Qiita #Bookmark');
else if (window.location.href.startsWith('http://www.slideshare.net/')) lines.push('#SlideShare #Bookmark');
else if (window.location.href.startsWith('https://speakerdeck.com')) lines.push('#SpeakerDeck #Bookmark');
else lines.push('#Bookmark');
lines.push('');
var body=encodeURIComponent(lines.join('\n'));
window.open('https://scrapbox.io/ohtomi/'+encodeURIComponent(title.trim())+'?body='+body)})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment