Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/688406d1-62a4-8012-949f-ac50d0247df3
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{DISPLAYTITLE:Share process with instructions}} ''This conversation was exported from ChatGPT''<ref>{{cite web|title=Share process with instructions|url=https://chatgpt.com/share/688406d1-62a4-8012-949f-ac50d0247df3|publisher=ChatGPT|access-date=2025-11-15}}</ref> == o3 == === User: I'd like to share what I did with the Google Sheet and Cozyla on a Cozyla FB group. === I'd like to share what I did with the Google Sheet and Cozyla on a Cozyla FB group. Can share the process we came up with, generate simple step by step instructions and the code in case someone would like to try to do this themselves? replace all of my API KEY, GUIDS, and identifying code with placeholders. === Assistant: Below is a concise “how‑to” you can paste directly into a Cozyla / Google Apps Script post. === Below is a concise “how‑to” you can paste directly into a Cozyla / Google Apps Script post. All service‑specific secrets, GUIDs, and URLs have been replaced with easy‑to‑spot place‑holders (ALL‑CAPS in angle brackets) so no sensitive data leaks. ==== A tiny Google Apps Script that: ==== # Publishes a specific sheet tab as a bare‑bones HTML widget. # Screenshots that widget (via Thum.io or ScreenshotAPI) at a fixed size & crop. # Stores the PNG in a Drive folder (overwriting the prior version to keep the URL stable). # Feeds that stable PNG link to a Cozyla Web Image widget—so your dashboard always shows the latest data. ==== | | | | ==== | --- | --- | --- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ==== <syntaxhighlight lang="javascript">/** ==== * ========= CONFIG ========= */ const PUBLISHED_URL = '<PUBLISHED_SHEET_WIDGET_URL>'; // e.g. https://docs.google.com/… const FOLDER_ID = '<TARGET_DRIVE_FOLDER_ID>'; // folder where PNG lives const PNG_NAME = 'sheet_widget.png'; // keep constant for a stable link const PROP_KEY = 'PNG_FILE_ID'; // ScriptProperty key const SCREENSHOT_API = 'https://image.thum.io/get/'; // swap for ScreenshotAPI if preferred const SCREENSHOT_API_KEY = '<YOUR_SCREENSHOT_SERVICE_KEY>'; // leave blank if not required /** * Add a cache‑buster so the service re‑captures every call. * Modify width/crop params to suit your Cozyla display. */ function buildScreenshotUrl(url) { // Thum.io example: …/width/1024/crop/700/noanimate/<ENCODED_URL>?auth=<KEY> const width = 1024; // px const cropH = 700; // px const encoded = encodeURIComponent(url); const auth = SCREENSHOT_API_KEY ? <code>?auth=${SCREENSHOT_API_KEY}</code> : ''; const cb = auth ? '&' : '?'; // chain correctly return <code>${SCREENSHOT_API}width/${width}/crop/${cropH}/full/${encoded}${auth}${cb}cb=${Date.now()}</code>; } /** * Main entry point – grabs fresh screenshot & stores/updates PNG in Drive. */ function snapshotSheetToPng() { // 1) Build screenshot URL const shotUrl = buildScreenshotUrl(PUBLISHED_URL); // 2) Fetch the PNG blob const response = UrlFetchApp.fetch(shotUrl, { muteHttpExceptions: true, followRedirects: true }); if (response.getResponseCode() !== 200) { throw new Error(<code>Screenshot capture failed ‑‑ HTTP ${response.getResponseCode()}</code>); } const pngBlob = response.getBlob().setName(PNG_NAME); // 3) Ensure target Drive folder exists const folder = DriveApp.getFolderById(FOLDER_ID); // 4) Check if we’ve already saved a file for this widget const storedId = PropertiesService.getScriptProperties().getProperty(PROP_KEY); let file; if (storedId) { try { file = DriveApp.getFileById(storedId); file.setContent(pngBlob.getBytes()); // overwrite existing bytes } catch (e) { // File was deleted; fall through to create‑new } } if (!file) { file = folder.createFile(pngBlob); PropertiesService.getScriptProperties().setProperty(PROP_KEY, file.getId()); file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW); } Logger.log(<code>Updated PNG → ${file.getUrl()}</code>); } </syntaxhighlight> ===== | | | ===== | --- | --- | | | | | | | | | | | | | ==== - Crop/size tweaks – play with width & crop height until the widget fills Cozyla cleanly. ==== * Multiple widgets – duplicate snapshotSheetToPng with new constants for each sheet. * Security – the Drive PNG is public‑read; if that worries you, keep it in a shared‑drive limited to Cozyla’s service account. * Rate limits – free tiers usually allow 100–250 captures/day. Adjust trigger frequency accordingly. Share away—your fellow Cozyla tinkerers should be able to replicate the display in under 15 minutes. 🎉 === User: Describe in detail where the user can find the constants at for the script. === Describe in detail where the user can find the constants at for the script. and how to run the script and then how to deploy the script with a trigger. === Assistant: 1 Where to locate & edit the constants === ===== 1 Where to locate & edit the constants ===== # Open the bound Apps Script project - In your Google Sheet choose Extensions → Apps Script (this opens the online code editor at script.google.com). # Find the constant block - In the default Code.gs file you’ll see a comment header /** ========= CONFIG ========= */ Immediately below it are the five constants you must change: ``<code>javascript const PUBLISHED_URL = '<PUBLISHED_SHEET_WIDGET_URL>'; const FOLDER_ID = '<TARGET_DRIVE_FOLDER_ID>'; const PNG_NAME = 'sheet_widget.png'; const PROP_KEY = 'PNG_FILE_ID'; const SCREENSHOT_API = 'https://image.thum.io/get/'; const SCREENSHOT_API_KEY = '<YOUR_SCREENSHOT_SERVICE_KEY>'; </code>`<code> # What to paste into each placeholder | Constant | Where to get the value | | ------------------ | ------------------------------------------------------------------------------------------------------------------------ | | PUBLISHED_URL | In the Sheet: File → Share → Publish to web. Choose the specific tab and click Publish. Copy the URL that appears and paste it (keep the single quotes). | | FOLDER_ID | Create or pick a Drive folder → open it → copy the long ID from the URL (the string after folders/). Example: https://drive.google.com/drive/folders/'''1A2B3C...''' | | PNG_NAME | Leave as‑is unless you want a different filename. | | PROP_KEY | Leave as‑is (it’s just an internal reference). | | SCREENSHOT_API | Leave default for Thum.io, or replace with ScreenshotAPI’s base endpoint if you use that service. | | SCREENSHOT_API_KEY | Paste your Thum.io or ScreenshotAPI key (between quotes) or leave blank if the service doesn’t require authentication. | ===== 2 How to run the script the first time ===== # In the Apps Script editor, click the function‑picker drop‑down (upper‑left, just to the right of the debug bug icon) and select </code>snapshotSheetToPng`. # Press the ► Run button. # A permissions dialog appears: - Click Review permissions, choose your Google account, then Allow the requested scopes (Drive write, external requests). # Watch the Execution log (View → Logs). You should see Updated PNG → https://drive.google.com/file/d/…/view. # Open the target Drive folder—sheet_widget.png should be there. Right‑click → Get link and confirm the sharing setting is Anyone with the link → Viewer (that makes the image accessible to Cozyla). ===== 3 How to deploy the script on an automatic trigger ===== # In the Apps Script toolbar click the ⏰ Triggers icon (left sidebar) or choose Triggers from the left navigation panel (it looks like a clock). # Click + Add Trigger (lower‑right). # Fill out the dialog: - Choose which function to run: snapshotSheetToPng - Choose which deployment should run: Head (default) - Select event source: Time‑driven - Select type of time‑based trigger: For most dashboards: Hour timer or Minute timer (e.g., “Every 15 minutes” keeps the widget fresh without burning free‑tier limits.) - Click Save. # Accept the authorization prompt if it reappears—Apps Script needs separate consent for triggers. # The trigger now shows in the list with the next scheduled run time. From here you can: - Edit frequency by clicking the pencil icon. - Monitor executions under Executions in the left sidebar. - Delete/disable if you hit service rate limits. ===== Quick test that everything works ===== * Wait for the first scheduled trigger or manually press ► Run again. * Refresh Cozyla; the Web Image widget should now show the latest screenshot. * Check Drive file Version history (Right‑click → Manage versions) to confirm the PNG is updating instead of creating duplicates. That’s it—constants edited, script authorized, trigger deployed, and your Cozyla dashboard stays in sync automatically. == References == <references /> [[Category:ChatGPT Shares]] [[Category:openai]]
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Cite web
(
edit
)
Module:Citation/CS1
(
edit
)
Module:Citation/CS1/COinS
(
edit
)
Module:Citation/CS1/Configuration
(
edit
)
Module:Citation/CS1/Date validation
(
edit
)
Module:Citation/CS1/Identifiers
(
edit
)
Module:Citation/CS1/Utilities
(
edit
)
Module:Citation/CS1/Whitelist
(
edit
)
Module:Citation/CS1/styles.css
(
edit
)