Skip to content

Instantly share code, notes, and snippets.

Avatar

Yusuke S. UskeS

View GitHub Profile
@UskeS
UskeS / manifest.json
Created September 5, 2023 00:25
InDesign UXP Plugin manifest
View manifest.json
{
"id": "your_plugin_id",
"name": "your_plugin_name",
"version": "1.0.0",
"main": "index.html",
"host": [
{
"app": "ID",
"minVersion": "18.5.0"
}
@UskeS
UskeS / pdfPageRangeReset.jsx
Created April 6, 2023 04:26
[InDesign]PDF書き出しページ範囲をリセットするスクリプト
View pdfPageRangeReset.jsx
//@targetengine "PDFpageRangeReset"
app.addEventListener("afterOpen", myFunc, false);
function myFunc(e) {
app.pdfExportPreferences.pageRange = "0";
}
@UskeS
UskeS / getMedian.gs
Created September 6, 2022 11:35
[GAS]特定のセルから数値を拾い上げ中央値(メディアン)を取る関数
View getMedian.gs
function getMedianByMonth(tagetYear, targetMonth) {
const currentSS = SpreadsheetApp.getActiveSpreadsheet();
const targetSheet = currentSS.getSheetByName(tagetYear);
const targetRange = targetSheet.getDataRange();
const tagetValues = targetRange.getValues();
const result = tagetValues.filter(el => el[2] == targetMonth).map(x => x[9]);
const median = (ary) => {
if (ary.length === 0) {
return 0;
}
@UskeS
UskeS / mm2inch.js
Created March 31, 2022 03:49
[JXA][Automator] 選択したmm単位表記テキストをinch単位に変換して置換する
View mm2inch.js
function run(input, parameters) {
var input = parseFloat(input[0]);
return (Math.round(input * 1000 / 254) / 100) + "";
}
@UskeS
UskeS / overrideUpperHalfMasterPageItems.jsx
Created March 15, 2022 10:23
[InDesign] ページ上半分のマスターページアイテムをオーバーライドするスクリプト
View overrideUpperHalfMasterPageItems.jsx
/**
* @fileoverview ページ上半分のマスターページアイテムをオーバーライドするスクリプト
* @author Yusuke SAEGUSA
* @version 0.0.1
*/
var myDoc = app.activeDocument;
var pag = myDoc.pages;
for (var i = 0, len = pag.length; i < len; i++) {
var halfHeight = (pag[i].bounds[2] - pag[i].bounds[0]) / 2; //ページの半分
@UskeS
UskeS / extractAnnots.js
Last active April 6, 2023 21:54
[Acrobat]コメントを抽出してテキストファイルに書き出すAcrobat用スクリプト
View extractAnnots.js
var result = [];
for (var i = 0; i < numPages; i++) {
var annot = getAnnots(i); // ページに含まれる注釈コメント
if (!annot) { continue; } // nullが返ることがあるのでFalsyなら飛ばす
for (var j = 0, lenAnnot = annot.length; j < lenAnnot; j++) {
var myAnnots = [];
myAnnots.push("p." + (annot[j].page + 1));
myAnnots.push(annot[j].contents.replace(/\r/g, "<br>"));
result.push(myAnnots.join("\t")); // 区切り文字
}
@UskeS
UskeS / AccessYahooAPISample.js
Last active October 24, 2021 10:20
Yahoo! テキスト解析APIへExtendScriptを利用してPOSTリクエストを送るサンプル(Mac版InDesign専用)
View AccessYahooAPISample.js
if (!String.prototype.surroundQuotes) {
String.prototype.surroundQuotes = function(q) {
return q + this + q;
}
}
var p = {
url: "https://jlp.yahooapis.jp/FuriganaService/V2/furigana",
header: {
contentType: "application/json",
userAgent: "Yahoo AppID: <アプリケーションID>", //ここにClientIDを記述
@UskeS
UskeS / toggleProofingType.js
Created March 25, 2021 01:54
[InDesign][ExtendScript] Toggle between "Dot Gain 15%" and "Working CMYK" for display proofing settings.
View toggleProofingType.js
/**
* @fileoverview Toggle between "Dot Gain 15%" and "Working CMYK" for display proofing settings.
* @author @Uske_S
* @version 0.1.0
*/
var actWin = app.activeWindow;
if (actWin.proofingType === ProofingType.CUSTOM) {
actWin.proofingType = ProofingType.WORKING_CMYK;
} else {
@UskeS
UskeS / BreakTextThread_mod.jsx
Created February 13, 2021 02:14
InDesign sample script - BreakTextThread.jsx - modified version. It also works fine on the frame grid.
View BreakTextThread_mod.jsx
//DESCRIPTION:Break text thread
/*
About Script
InDesign makes breaking of thread between text frames without otherwise changing the layout surprisingly difficult!
With this script, easily break the text thread
(a) between selected text frames
(b) between all frames in the selected story,
(c) throughout the document according to a selected paragraph style (great for dividing a long document into separate stories, one per chapter)
@UskeS
UskeS / disassemblyParenNum.jsx
Created September 16, 2020 06:53
[ExtendScript] [InDesign] 括弧数字を閉じたり開いたりするスクリプト
View disassemblyParenNum.jsx
/**
* 選択状態のバリデーション
*/
if (app.documents.length === 0) myError("NOT_OPENED_DOCUMENT");
if (app.documents[0].selection.length === 0) myError("INVALID_SELECTION");
/**
* メイン処理
*/
var doc = app.activeDocument;