Skip to content

Instantly share code, notes, and snippets.

@dmadisetti
Forked from bavardage/gist:939140
Last active November 29, 2023 04:31
Show Gist options
  • Save dmadisetti/d21d292f69fbec6a9499 to your computer and use it in GitHub Desktop.
Save dmadisetti/d21d292f69fbec6a9499 to your computer and use it in GitHub Desktop.
Google Docs Hack
#!/bin/sh
# Short script to auto format on save
MATCHING=false;
press(){
xte "$1";
if [ "x" = "$2x" ]; then
sleep 0.05;
else
sleep 0.2;
fi
}
run(){
MATCHING=false;
# Select all
press "keydown Control_R" x;
press "key a";
press "keyup Control_R";
# Tools->Addons->Code->Selection->Enter
press "keydown Alt_R" x;
press "key b";
press "keyup Alt_R";
press "key Right";
press "key Down";
press "key Right";
press "key Return";
}
prime(){
MATCHING=true;
}
match(){
while read line; do
if [ "$MATCHING" = true ] ; then
echo $line | grep "press 39" && run; # S press
else
MATCHING=false;
echo $line | grep "press 37" && prime; # Ctrl press
fi
done
}
xinput test $1 | match;
@dmadisetti
Copy link
Author

dmadisetti commented Jan 28, 2021

@ILikeCheating Maybe an older version of google docs?
You did need the code pretty print plugin, which is now blocked.
Maybe using code-blocks it'll work? https://workspace.google.com/marketplace/app/code_blocks/100740430168

This script works by navigating the tool menu and auto selecting format code, so adapt it for whatever menu options you have

@dmadisetti
Copy link
Author

From the shortcut list

    press "keydown Alt_R" x;
    press "key b";

Should now be

    press "keydown Alt_R" x;
    press "key n";

to pop the addons menu

@RavenChill-Dev
Copy link

Hi! So im a lead general and co-owner of this major google doc called glicthquake, and we are currently at war against glitch wires, another doc, im wondering what this hack does, and if it gives ownership/edit on documents.

@dmadisetti
Copy link
Author

No, but you could extend it to do that. This just applied a plugin for formatting code in a Google doc. I made it when I went through Google interviews (code questions in a doc are pretty dumb)

@RavenChill-Dev
Copy link

Ty, but the war is over. LOL

@INEEDHACKSS
Copy link

is this supposed to be a bookmarklet?

@dmadisetti
Copy link
Author

It's a bash script to emulate keypresses and run a google docs plugin on a certain key strokes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment