Scripts

These are miscellaneous bash and Python scripts I find myself using often.

The Python scripts require at least version 3.6+.

All of these programs except for baleet_mac_garbage.sh are released under the terms of the GNU General Public License, version 3 or later. The full text of the license is available through the git repo or the link in License, below.

Download

git clone https://www.twinkle-night.net/Code/scripts.git

See sub-sections for direct downloads of individual programs.

baleet_mac_garbage.sh

This is only three real lines, so it hardly merits a separate file, but if you’re annoyed by __MACOSX and .DS_STORE bits (I am), this is an easy way to recursively delete all of them from the current directory. Despite the name, it takes out Thumbs.db as well.

#!/bin/bash

find . -type d -iname "__MACOSX" -prune -exec rm -rf {} \;
find . -type f -iname ".DS_STORE" -exec rm -f {} \;
find . -type f -iname "Thumbs.db" -exec rm -f {} \;

To the extent possible under law, garrick has waived all copyright and related or neighboring rights to baleet_mac_garbage.sh. This work was published from the United States.

clean_filenames.py

Pass this a directory and it’ll clean some annoying characters from filenames in that directory:

They’ll all be replaced with underscore (_). It doesn’t recurse into subdirectories or anything like that. All its dependencies are in the standard library.

Syntax: clean_filenames.py .

This was just a quick and dirty thing I made for my own purposes, so it’s prone to errors. There is no easy way (if there is one at all) to return filenames to what they were before. I take no responsibility for any loss of data or other issues you might encounter.

Download clean_filenames.py | Signature

fountain2rpy.py

Convert a Fountain screenplay to a Ren’Py .rpy script. Very messy and barebones; it doesn’t recognize most elements from the Fountain spec. It was designed specifically for people who use Fountain syntax to write Ren’Py games, not general-purpose conversion of screenplays to visual novels.

This is actually how I write the scenarios for all my Ren’Py games—so it does function for my personal workflow, at least.

Syntax: fountain2rpy.py saffron.fountain

INT./EXT. statements parse to scenes, and scene lines that are forced with a dot (e.g. . karen) parse to showing images. Transition instructions like CROSSFADE TO: are just rendered as comments. ^_^;; Descriptive lines and lines attributed to “NARR.”, etc. are given to the narrator, and other lines that seem like dialogue get a lowercase version of their speaker as a Character. (No characters or images are defined by the script, incidentally.) It gets easily confused by allcaps lines that aren’t character names or INT./EXT. statements, so be careful about using those.

Example input (test.fountain):

Title: Test
Credit: written by
Author: Matthew Ellison
Copyright: Copyright 2019 Twinkle Night. Some rights reserved.

We are the chick and the egg is the world.

====

EXT. FOREST

A bear drives up in a red sports car.

. bear

NARR.
The bear is square.

BEAR
Don't listen to him.

BEAR (CONT'D)
Bears are the beginning and end of the world.

> _**THE END**_ <

Example output (test.rpy):

## Title: Test
## Credit: written by
## Author: Matthew Ellison
## Copyright: Copyright 2019 Twinkle Night. Some rights reserved.
## We are the chick and the egg is the world.

    ################################SCENE CHANGE################################

    scene forest
    with dissolve

    "A bear drives up in a red sports car."

    show bear
    with dissolve

    "The bear is square."

    bear "Don't listen to him."

    bear "Bears are the beginning and end of the world."

    return

Requires awesome-slugify.

Download fountain2rpy.py | Signature

pdf2cbz.sh

Extract the images from PDF files and create a CBZ comic archive from them. Does not work for 100% of PDFs—if the PDF has non-raster elements, or its layout uses multiple small image layers with transparency instead of full-page pictures, pdf2cbz’s output will have problems. It has some basic error checking, but is still pretty ugly.

Syntax: pdf2cbz.sh BrutusGaiden.pdf

Requires pdfimages, ImageMagick, and 7-zip.

Download pdf2cbz.sh | Signature

tag_springheel.py

Looks over transcripts in a Springheel site and recommends tags based on character names. (It only lists possible tags for each page; no actual changes are made to any files.) You’ll definitely want to check over the output before using it for anything. You need the input/ directory, not an already-generated site from output/, for this to run.

Edit the list of auto-rejected names as needed. It defaults to: "SFX", "Narrator", "Narration", "Caption", "Title", "Legend", "Offscreen Voice", "Unseen Voice", "Unknown Person", "Man", "Mysterious Voice".

Syntax: tag_springheel.py input/

Requires logging and awesome-slugify.

Download tag_springheel.py | Signature

Userscripts

I don’t actually know JS, so there aren’t many of these; all the scripts here were made through pure trial and error.

AO3 - Remove Blank Lines

For some reason, many stories on Archive of Our Own contain stray blank lines between some paragraphs (seemingly at random). I have the line-height set relatively high, so these got a bit annoying—but I quickly found that they contained non-breaking space elements, so e.g. a custom stylesheet with :-moz-only-whitespace {display: none} would not work. My only choice was to figure out a way to remove elements with JS. And I did!

Download AO3_-_Remove_Blank_Lines.user.js

Userstyles

I rely heavily on Stylem and Stylus to customize the websites I visit (mostly to make text more readable—bigger, higher contrast, etc.). Here are some of the stles I rely on for daily use.

Make Chaotic Shiny Bigger

Massively increase the text size on Chaotic Shiny. It’s a bit buggy and relies on some newer browser elements (vw, grid), but it’s better than the layout when simply zooming in.

Download biggerchaoticshiny.user.css

Real Ultimate Link Color Fix

I want hyperlinks to be easily identifiable. Some sites do evil things like removing underlining and bottom borders + making them the same color as regular text, which annoys me. This stylesheet fixes their little red wagon.

Across all websites, this underlines all links; turns unvisited hyperlinks blue, visited ones purple, and hovered/active/focused ones red (images that are links get a border of the appropriate color); and adds a white background to links to make the color stand out on sites with dark themes.

This will look weird on some sites. I included hacks for Archive of Our Own and tumblr because they in particular were ugly, but make no guarantees about other sites.

Download realultimatelinkcolorfix.user.css

Real Ultimate Link Color Fix - Dark Variant

If you prefer dark colors (or the people who design the websites you use a lot do), this might be less intrusive than the vanilla Real Ultimate Link Color Fix.

Download darkultimatelinkcolorfix.user.css

Changelog

1.1.0

1.0.0

License

Copyright 2019 Matthew Ellison.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses or write to:

Free Software Foundation
51 Franklin Street, Fifth Floor
Boston, MA 02110-1335
USA