Skip to content

Instantly share code, notes, and snippets.

View joonaspaakko's full-sized avatar
🍕
Pizza...

Joonas Pääkkö joonaspaakko

🍕
Pizza...
View GitHub Profile
/*
NOTE:
1. Makes the assumption that only one layer is selected (only really matters when going down)
2. Doesn't care if the adjacent layer is a group or not
*/
var options = {
direction: 'up',
loop: true,
};
// Mark all Audible library books ON THE CURRENT PAGE as finished or unfinished
// The script is basically a macro: it works by emulating a button click and just automating it for every single book
function markAs(config) {
config = config || {};
var i = 0;
var elements = $(config.finished ? ".mark-as-finished-button" : ".mark-as-unfinished-button");
var l = elements.length;
(function fn() {
const item = elements[i++];
$(item).find("button").click();
@joonaspaakko
joonaspaakko / Batch Mockup Smart Object Replacement.jsx
Created March 13, 2023 20:11
Batch Mockup Smart Object Replacement.jsx (random lengthy output)
// v.1.6.
// Batch Mockup Smart Object Replacement.jsx
// You'll need to incplude this file to another script file:
// #include "../script/Batch Mockup Smart Object Replacement.jsx"
// Check the example folders for a few real world examples.
// Minimal settings
/*
@joonaspaakko
joonaspaakko / Export document for each layer inside selected group - scale doc 10x.jsx
Last active May 12, 2022 09:22
Export document for each layer inside selected group - scale doc 10x
// Name: Export document for each layer inside selected group.jsx
// Formerly: Export Layers Inside Selected Group.jsx
// Description: Photoshop script that saves the whole document for each top level layer inside the selected group.
// Image example: https://user-images.githubusercontent.com/1164476/49152494-aef8af00-f31b-11e8-80ff-d774e3103eae.png
// https://gist.github.com/joonaspaakko/013a223e94ba0fb9a2a0
#target photoshop
@joonaspaakko
joonaspaakko / Read and write text.jsx
Created October 11, 2021 07:54
Read and write text example in Adobe extendscript
// In this demo:
// 1. I first prep the output file path
// 2. Then write the text file: "current date and time + some placeholder text"
// - As long as you don't change the path, it gets written next to this script file.
// 3. Then read the text file
// 4. And finally trigger alert() to show the text that was written.
// - At the top it shows each line as an array
// - And below that it just shows the full text as it was written.
// https://gist.github.com/joonaspaakko/df2f9e31bdb365a6e5df
// Finds all .ai files from the input folder + its subfolders and converts them to the version given below in a variable called "targetVersion"
// Tested in Illustrator cc 2014 (Mac)
// Didn't bother to do a speed test with my macbook air...
#target illustrator
// If set to false, a new file will be written next to the original file.
var selection = app.selection[0];
var zIndex = getStackingIndex( selection, true );
$.writeln( zIndex );
// Since the last parameter is set to false, this selectPageItem() mirrors the selection
// - If first item is selected when the script is run, the last one will be
// selected when the script is done.
selectPageItem( selection.parentPage, zIndex, false );
@joonaspaakko
joonaspaakko / Select All Layers.jsx
Last active December 20, 2019 20:54
Photoshop script for selecting all layers, including the background layer.
selectAllLayers();
function selectAllLayers() {
// Select all layers (doesn't include Background)
try {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( stringIDToTypeID('selectAllLayers'), desc, DialogModes.NO );
// Set true to "normalize" the character styled text = no extra leading & trailing spaces
var removeSpace = false;
app.findTextPreferences = null;
app.changeTextPreferences = null;
var findPref = app.findTextPreferences;
var changePref = app.changeTextPreferences;
findPref.appliedCharacterStyle = 'yellow-background';
@joonaspaakko
joonaspaakko / Select Next Layer (invisible or not).jsx
Last active February 26, 2024 21:46
Photoshop script that selects the next layer above or below even if it's not visible.
// Select Next Layer (invisible or not).jsx
// https://gist.github.com/joonaspaakko/048c9b58ccbb6e6f44c894bf4ce30b68
nextLayer('down');
// direction (↑): "up" or "above"
// direction (↓): "down" or "below"
function nextLayer( direction ) {
var doc = app.activeDocument;