Skip to content

Instantly share code, notes, and snippets.

@pghant
pghant / Clash Upgrades.scriptable
Created July 27, 2025 23:43
Clash Upgrades Widget
{
"always_run_in_app" : false,
"icon" : {
"color" : "yellow",
"glyph" : "gavel"
},
"name" : "Clash Upgrades",
"script" : "const DATA_MAP_URL = 'https:\/\/gist.githubusercontent.com\/pghant\/0717bb1e0e4e0d1373e90bdb3057d9dd\/raw\/dc943f912a7d30cf559349b415c0b4d21c3cad0e\/cocMapping.json';\nconst DATA_MAPPING = await (new Request(DATA_MAP_URL)).loadJSON();\nconst TABLE_WIDTH = {\n COL_1: 140,\n COL_2: 60,\n COL_3: 110\n}\n\nfunction createTable(widget, headerContent, tableContent, colWidths) {\n const fontSize = 12;\n\n const headerRow = widget.addStack();\n headerRow.layoutHorizontally();\n headerContent.forEach((cellContent, idx) => {\n const cell = headerRow.addStack();\n const text = cell.addText(cellContent);\n text.font = Font.mediumSystemFont(fontSize);\n cell.size = new Size(colWidths[idx], 0);\n });\n\n for (const rowContent of tableContent) {\n const row = widget.addStack();\n row.layoutHorizontally();\n rowContent.forEach((cellContent, idx) => {\n
@pghant
pghant / cocMapping.json
Last active December 24, 2025 13:02
Clash of Clans JSON Export Mapping
[
{ "name": "Crafted Defense", "dataId": 1000097 },
{ "name": "Cannon", "dataId": 1000008 },
{ "name": "Archer Tower", "dataId": 1000009 },
{ "name": "Mortar", "dataId": 1000013 },
{ "name": "Air Defense", "dataId": 1000012 },
{ "name": "Wizard Tower", "dataId": 1000011 },
{ "name": "Air Sweeper", "dataId": 1000028 },
{ "name": "Hidden Tesla", "dataId": 1000019 },
{ "name": "Bomb Tower", "dataId": 1000032 },