PCでスクマ
PCでスクマ
最終形は以下。
code:script.js
javascript:(function(){var project = "inteltank";var title = document.title;var metaDiscre = document.head.children;var metaLength = metaDiscre.length;var imageURL;for(var i = 0;i < metaLength;i++){var proper = metaDiscrei.getAttribute('property');if(proper === 'og:image'){imageURL = metaDiscrei.content.replace(/"|'/,'');}}var d = new Date();var today = d.getFullYear(),(d.getMonth()+1),d.getDate().join('/');var URL = window.location.href.replace(/"|'/,'');var quote=window.getSelection().toString();var body = [""+imageURL+"",title,URL,">"+quote,""+today+"にpick","","リンク未整理"];var body_final = encodeURIComponent(body.join('\n'));window.open('https://scrapbox.io/'+project+'/'+encodeURIComponent(title.trim())+'?body='+body_final)})(); hr.icon
作成作業を…メモしておいた。今後役にたつかもなので。
まずはScrapbox謹製のスクマを調べる
code:javascript
javascript:(function()%7Bvar title%3Dwindow.prompt(%27Scrap "Scrapbox" to inteltank.%27,document.title)%3Bif (!title) return%3Bvar lines%3D%5B%27%27,%27%5B%27%2Bwindow.location.href%2B%27 %27%2Bdocument.title%2B%27%5D%27%5D%3Bvar quote%3Dwindow.getSelection().toString()%3Bif (quote.trim()) lines%3Dlines.concat(quote.split(/%5Cn/g).map(function(line)%7Breturn %27 > %27%2Bline%7D))%3Blines.push(%27%27)%3Bvar body%3DencodeURIComponent(lines.join(%27%5Cn%27))%3Bwindow.open(%27https://scrapbox.io/inteltank/%27%2BencodeURIComponent(title.trim())%2B%27%3Fbody%3D%27%2Bbody)%7D)()%3B このままだと見にくいので、まずデコードする
code:javascript
デコードしたものを改行する
code:javascript
javascript:(function(){
var title=window.prompt('Scrap "Scrapbox" to inteltank.',document.title);
if (!title)
return;
var quote=window.getSelection().toString();
if (quote.trim())
lines=lines.concat(quote.split(/\n/g).map(function(line){return ' > '+line}));
lines.push('');
var body=encodeURIComponent(lines.join('\n'));
})();
うむむ…browser上で、javascriptがどう動くのか?一つずつ試したいtsawada.icon
調べてみた。
便利らしい。使ってみる
あれ、javascript consoleが見つからない。verが新しくなって亡くなったのかしら
code:画像URLを見つけ出す.js
javascript:(function(){
//初期設定
var project = "inteltank";
//title設定
var title = document.title;
//画像URLを見つけ出す
var metaDiscre = document.head.children;
var metaLength = metaDiscre.length;
var imageURL;
for(var i = 0;i < metaLength;i++){
var proper = metaDiscrei.getAttribute('property'); if(proper === 'og:image'){
imageURL = metaDiscrei.content.replace(/"|'/,''); }
}
//今日の日付を見つけ出す
var d = new Date();
//ページURLを取得する
var URL = window.location.href.replace(/"|'/,'');
//選択範囲を取得する
var quote=window.getSelection().toString();
//最終的な本文
var body = [
imageURL,
title,
URL,
">"+quote,
"",
var body_final = encodeURIComponent(body.join('\n'));
})();
まずコメントをなくす
code:
code:コメントなくした後.js
javascript:(function(){
var project = "inteltank";
var title = document.title;
var metaDiscre = document.head.children;
var metaLength = metaDiscre.length;
var imageURL;
for(var i = 0;i < metaLength;i++){
var proper = metaDiscrei.getAttribute('property'); if(proper === 'og:image'){
imageURL = metaDiscrei.content.replace(/"|'/,''); }
}
var d = new Date();
var URL = window.location.href.replace(/"|'/,'');
var quote=window.getSelection().toString();
var body = [
title,
URL,
">"+quote,
"",
var body_final = encodeURIComponent(body.join('\n'));
})();
作ったので、改行をなくし、encodeする
code:改行・タブをなくしたもの.js
javascript:(function(){var project = "inteltank";var title = document.title;var metaDiscre = document.head.children;var metaLength = metaDiscre.length;var imageURL;for(var i = 0;i < metaLength;i++){var proper = metaDiscrei.getAttribute('property');if(proper === 'og:image'){imageURL = metaDiscrei.content.replace(/"|'/,'');}}var d = new Date();var today = d.getFullYear(),(d.getMonth()+1),d.getDate().join('/');var URL = window.location.href.replace(/"|'/,'');var quote=window.getSelection().toString();var body = [""+imageURL+"",title,URL,">"+quote,""+today+"にpick","","リンク未整理"];var body_final = encodeURIComponent(body.join('\n'));window.open('https://scrapbox.io/'+project+'/'+encodeURIComponent(title.trim())+'?body='+body_final)})();