๐ Google Apps Script Files
This folder contains all Google Apps Script (GAS) files for the Tokyo VPN Speed Monitor system.
๐๏ธ Architecture Overview
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Main Spreadsheet โ
โ (Speed Data, Price History, Outage, News, Reports) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โ
โ vpn-speed-tracker.gs โโโโโโ โ
โ price-scraper.gs โโโโโโโโโโโโผโโโบ Data Collection โ
โ outage-detection.gs โโค โ
โ news-monitor.gs โโโโโโโ โ
โ โ
โ twitter-poster.gs โโโโโโโโโโโโโโบ Notifications โ
โ price-alert.gs โโโโโโโโโโโโโโโโโโโบ โ
โ โ
โ market-report.gs โโโโโโโโโโโโโโบ Reporting โ
โ weekly-digest.gs โโโโโโโโโโโโโโโโโโโโโบ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Separate Spreadsheet (Trust Score) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ trust-score.gs โโโโโโโโโโโโโโโโโบ Trust Evaluation โ
โ (Uses Claude API for automated assessment) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ File Descriptions
Core Engines
| File | Engine | Description | Trigger |
|---|---|---|---|
speed-tracker.gs | 1 | Speed measurement for 15 VPNs | Every 6 hours |
price-scraper.gs | 2a | Price scraping with ScraperAPI | Daily 9:00 AM |
price-alert.gs | 2a+ | Price change detection & alerts | After price scraping |
outage-detection.gs | 2b | Statistical anomaly detection | Hourly |
news-monitor.gs | 2b+ | Google News RSS monitoring | Every 6 hours |
Notification & Reporting
| File | Description | Trigger |
|---|---|---|
twitter-poster.gs | Twitter OAuth 1.0a posting (speed + trust) | 10:00, 15:00, 20:00 / Monthly 1st |
weekly-digest.gs | Weekly newsletter digest generator | Monday 9:00 AM |
market-report.gs | Quarterly market report with PDF | Quarterly 1st |
Trust Score (Separate Project)
| File | Description | Trigger |
|---|---|---|
trust-score.gs | Claude API-based trust evaluation | Monthly 1st, 10:00 |
Configuration
| File | Description |
|---|---|
config.example.gs | Configuration template (copy to config.gs) |
๐ง Setup Instructions
Step 1: Main Spreadsheet Setup
-
Create a new Google Spreadsheet
-
Go to Extensions โ Apps Script
-
Copy the following files:
speed-tracker.gsprice-scraper.gsprice-alert.gsoutage-detection.gsnews-monitor.gstwitter-poster.gsweekly-digest.gsmarket-report.gsconfig.example.gsโ rename toconfig.gsand fill in values
-
Create required sheets:
้ๅบฆใใผใฟVPNๆ้ๅฑฅๆญดVPN้ๅฎณๆค็ฅ๏ผ้ซๅบฆ๏ผVPNใใฅใผในๅฑฅๆญดVPNๆฅญ็็ตฑ่จใฌใใผใ้ฑๆฌกใใคใธใงในใ
Step 2: Trust Score Setup (Separate Project)
- Create a new Google Spreadsheet for Trust Score
- Go to Extensions โ Apps Script
- Copy
vpn-trust-score-system.gs - Set Script Property:
CLAUDE_API_KEY= your Anthropic API key - Run
initialSetup()to create sheets - Deploy as Web App
- Copy the deployed URL to main project's config
Step 3: Set Script Properties
In the main project, set these Script Properties:
| Property | Description |
|---|---|
SCRAPERAPI_KEY | ScraperAPI key for price scraping |
In the Trust Score project:
| Property | Description |
|---|---|
CLAUDE_API_KEY | Anthropic API key for Claude |
Step 4: Configure Triggers
Run these setup functions once:
// In main project:
setupTriggers(); // Speed measurement (6h)
setupPriceAlertTriggers(); // Price scraping (daily)
setupAdvancedOutageDetectionTriggers(); // Outage (hourly)
setupNewsMonitorTriggers(); // News (6h)
setupAllTriggers(); // Twitter posting
setupWeeklyDigestTrigger(); // Newsletter (weekly)
setupQuarterlyReportTrigger(); // Report (quarterly)
// In Trust Score project:
setupMonthlyTrigger(); // Trust evaluation (monthly)
Step 5: Deploy Web Apps
Deploy each project as a Web App:
-
Main Project (Speed/Price/Outage/News API)
- Deploy โ New deployment โ Web app
- Execute as: Me
- Who has access: Anyone
-
Trust Score Project (Trust Score API)
- Same process, separate deployment
๐ก API Endpoints
Main Project
| Endpoint | Description |
|---|---|
?type=ranking | Speed ranking data |
?type=stability | Stability scores (7-day) |
?action=getPricing | Latest price data |
Trust Score Project
| Endpoint | Description |
|---|---|
?action=getTrustScores | Trust scores for all VPNs |
?action=getIntegrated | Combined ranking (speed + price + trust) |
?action=getVPNDetail&vpn=NordVPN | Single VPN details |
?action=getJurisdiction | Jurisdiction database |
๐ Required API Keys
| Service | Purpose | Free Tier |
|---|---|---|
| ScraperAPI | Price scraping (JS rendering) | 1,000 req/month |
| Twitter API | Auto-posting | Free (with approval) |
| Claude API | Trust Score evaluation | Pay per token |
Estimated Costs
| Service | Monthly Usage | Cost |
|---|---|---|
| ScraperAPI | ~150 requests | Free |
| Twitter API | ~100 tweets | Free |
| Claude API | ~15 evaluations | ~$0.50 |
| Total | ~$0.50/month |
๐ Data Flow
[Speed Measurement] โโโบ ้ๅบฆใใผใฟ sheet โโโ
โ
[Price Scraping] โโโโโบ VPNๆ้ๅฑฅๆญด sheet โโผโโโบ [Engine 8 Report]
โ โ
[Outage Detection] โโโบ VPN้ๅฎณๆค็ฅ sheet โโค โ
โ โผ
[News Monitor] โโโโโโโบ VPNใใฅใผใน sheet โโ PDF Report
[Trust Score API] โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
[Twitter Bot] โโโบ Speed tweets (3x daily)
โโโบ Trust tweets (monthly)
โโโบ Price alerts (on change)
[MailPoet] โโโโโบ Weekly digest (Monday)
๐ Debugging
Test Functions
Each file includes test functions:
// Speed tracker
checkLatestData();
checkStability();
// Price scraping
testAllVPNsPricing();
quickPricingTest();
// Outage detection
testAdvancedOutageDetection();
// News monitor
testNewsMonitor();
// Twitter
testSpeedTweet();
testTrustScoreTweet();
// Trust Score
testSingleVPNEvaluation();
testIntegratedRanking();
// Market Report
testReportGeneration();
testDataCollection();
Common Issues
| Issue | Solution |
|---|---|
| "SCRAPERAPI_KEY not set" | Add key to Script Properties |
| "CLAUDE_API_KEY not set" | Add key to Script Properties |
| Twitter 401 error | Check OAuth credentials |
| "No data available" | Run measurement/scraping first |
| ScraperAPI 500 error | Site may be blocking; check fallback |
๐ Notes
- Timezone: All times are JST (Asia/Tokyo)
- Rate Limits: Built-in delays prevent API throttling
- Fallback Prices: Used when scraping fails
- Trust Score: Uses Claude Sonnet 4.5 for evaluation
- Separate Projects: Trust Score runs in its own spreadsheet for isolation
๐ License
MIT License - See LICENSE for details.