Google Sheets

Google Apps Script

Add a GunSpec menu and custom cell functions to any Google Sheet. Live data, auto-refresh, zero setup beyond pasting the script.

GunSpec-AppsScript.gs

Setup

1

Download the file using the button above

2

Open your Google Sheet

3

Go to Extensions > Apps Script

4

Delete any existing code in Code.gs and paste the entire contents of the downloaded file

5

Find the API_KEY constant and replace it:

const API_KEY = 'test_key';
6

Click Save (Ctrl+S), then refresh the Google Sheet

7

A GunSpec menu appears in the menu bar

Custom Cell Functions

Use these directly in any cell - they return live data:

FunctionExampleReturns
GUNSPEC_FIREARM=GUNSPEC_FIREARM("m4a1-carbine", "weight_kg")A single field value (e.g. 2.88)
GUNSPEC_LIST=GUNSPEC_LIST(20)2D array: name, manufacturer, caliber, country, year
GUNSPEC_SEARCH=GUNSPEC_SEARCH("carbine", 10)2D array of search results with headers

Spill ranges: GUNSPEC_LIST and GUNSPEC_SEARCH return multi-row results that spill into adjacent cells. Place them in a cell with empty space below and to the right.

Menu Actions

ActionWhat it does
Import FirearmsCreates a new sheet with all firearms (13 columns, auto-resized)
Import Firearm DetailPrompts for a slug, creates a field/value detail sheet
Compare FirearmsPrompts for two slugs, creates a side-by-side comparison
Search FirearmsPrompts for a query, creates a results sheet

Auto-Refresh on a Schedule

1

In the Apps Script editor, click the Triggers icon (clock) in the left sidebar

2

Click + Add Trigger

3

Choose function: importFirearms, event source: Time-driven, frequency: every hour/day

4

A fresh sheet with updated data is created on each run

Back to Assets