moveToDocs
https://gyazo.com/be763aa8d13183abb0926ab8be43df41
| 使い方
1.iconGoogle Docsの「script editor」を開く
https://gyazo.com/766ae8efcff666cd18cee69b35f2386f
2.iconCode.gsにgas.jsをコピペします
moveToDocs#61ab258775f3120000901527
https://gyazo.com/a98bd9140dbfae6fb9673a7d2cff7aa1
3.iconindex.htmlを作成して、コードをコピペします
https://gyazo.com/f9d73bec083a99ccab2f15274f628e5d
https://gyazo.com/1131d73923cef8d588d3712580e1e400
4.iconDeployする
https://gyazo.com/6918d9d5404cd34fea45bf58f19caafe
https://gyazo.com/16075d39297d9ae1e77133806b50907b
https://gyazo.com/1c4c29216073652f0b5553a0d8c838b1
5.icon生成されたURLをコピーします
https://gyazo.com/79af5f1c5ac7b2940be4625d6cabbd1a
6.iconscript.jsをprofile pageに貼り付け、GASURLにコピーしたURLを入れます
https://gyazo.com/0b2f92c1462ddef664c73a9744e7d498
| Sources
code:script.js
scrapbox.PageMenu.addMenu({
title: 'ToDocs',
image: 'https://i.gyazo.com/ec5c1ad4c86a7251b63fe309815a8715.png',
onClick: () => {
const GASURL = "https://script.google.com/macros/s/XXX/exec";
const pageElement = document.getElementsByClassName("lines")0;
const lineElements = pageElement.getElementsByClassName('line');
const lines = [];
for (let line of lineElements) {
lines.push(line.textContent);
}
const contents = lines.join("\n");
window.open(GASURL +
"?body=" + encodeURIComponent(contents));
}
});
code:gas.js
function doGet(e) {
const docs = DocumentApp.getActiveDocument();
const body = docs.getBody();
const text = body.editAsText();
text.setText(e.parameter.body);
return HtmlService.createTemplateFromFile('index.html').evaluate();
}
function getURL() {
return DocumentApp.getActiveDocument().getUrl();
}
code:index.html
<!DOCTYPE html>
<html>
<head>
<base target="_top">
</head>
<body style="text-align: center; margin-top: 100px;">
<a style="font-size: 50px;" href="<?= getURL() ?>">Open Docs</a>
</body>
</html>