Non AMP
Sky Blues Talk
  • Home
  • Forums
  • Coventry City Football Club
  • Coventry City General Chat
This is a mobile optimized page that loads fast, if you want to load the real page, click this text.

I made a thing that might help today (2 Viewers)

  • Thread starter shmmeee
  • Start date Monday at 9:04 AM
Forums New posts

shmmeee

Well-Known Member
  • Monday at 9:04 AM
  • #1
Got ChatGPT to code me a widget for my phone that shows the top five thread titles on the CCFC forum. So in theory I don’t have to come here and get sucked in and can just watch for a thread about a new signing. It works as a piece of software it does not work as a way to stop my coming on SBT too much. Thought I’d share.

iOS you need to download an app called Scriptable then create a new script, past the below in, save it with a name, and then add the scriptable widget to your Home Screen and choose run script and select the one you made.

Here’s what it looks like:


Here’s the script:




Code:
// SkyBlueTalk — CCFC Top Threads (polished)
// Medium/Small widget. Auto dark/light, club sky-blue gradient.
// Taps: header → forum, each row → thread.

// ── CONFIG ─────────────────────────────────────────────────────────────────────
const FEED_URL = "https://www.skybluestalk.co.uk/forums/coventry-city-general-chat.7/index.rss";
const MAX_ITEMS = 5;             // keep 3–6 for Medium, 2–4 for Small
const TITLE_LINE_LIMIT = 1;      // 1 = tidy, 2 = roomier
const SHOW_REL_TIME = true;      // show “· 1h” after title
const TRIM_PREFIXES = [
  /^match\s*thread[:\-\s]*/i,
  /^pre[-\s]?match[:\-\s]*/i,
  /^post[-\s]?match[:\-\s]*/i,
  /^transfer(s)?[:\-\s]*/i,
  /^\[\s*rumou?r\s*\]\s*/i
];
// Colors
const SKY = Color.dynamic(new Color("#69b9ff"), new Color("#2b86d1"));
const DEEP = Color.dynamic(new Color("#1a6db3"), new Color("#154e80"));
const TEXT = Color.dynamic(Color.black(), Color.white());
const SUBTLE = Color.dynamic(new Color("#334155"), new Color("#b0c4d9"));
// ───────────────────────────────────────────────────────────────────────────────

async function fetchRSS(url){
  const req = new Request(url);
  req.headers = { "User-Agent": "ScriptableWidget/1.1 (+iOS)" };
  return await req.loadString();
}

function parseRSS(xml){
  const items = [];
  const blocks = xml.match(/<item>[\s\S]*?<\/item>/g) || [];
  for (let i=0; i<Math.min(blocks.length, MAX_ITEMS); i++){
    const b = blocks[i];
    const t = textOf(b, "title");
    items.push({
      title: prettifyTitle(t),
      link: textOf(b, "link"),
      date: new Date(textOf(b, "pubDate") || Date.now())
    });
  }
  return items;
}

function textOf(block, tag){
  const m = new RegExp(`<${tag}>([\\s\\S]*?)<\\/${tag}>`, "i").exec(block);
  return (m ? m[1] : "").replace(/<!\[CDATA\[|\]\]>/g,"").trim();
}

function prettifyTitle(t){
  let s = t.replace(/\s+/g," ").trim();
  for (const rx of TRIM_PREFIXES) s = s.replace(rx,"");
  // collapse bracketed prefixes like [Tickets], (H), etc. at start
  s = s.replace(/^(\[.*?\]|\(.*?\))\s+/g,"");
  return s;
}

function timeAgo(d){
  const secs = Math.max(1, (Date.now() - d.getTime())/1000);
  if (secs < 60) return `${Math.floor(secs)}s`;
  const mins = secs/60;
  if (mins < 60) return `${Math.floor(mins)}m`;
  const hrs = mins/60;
  if (hrs < 24) return `${Math.floor(hrs)}h`;
  const days = hrs/24;
  return `${Math.floor(days)}d`;
}

function header(w){
  const h = w.addStack();
  h.layoutHorizontally();
  h.centerAlignContent();
  h.url = "https://www.skybluestalk.co.uk/forums/coventry-city-general-chat.7/";
  const badge = SFSymbol.named("soccerball");
  const img = h.addImage(badge.image);
  img.imageSize = new Size(14,14);
  img.tintColor = TEXT;
  h.addSpacer(6);
  const t = h.addText("SkyBlueTalk — CCFC");
  t.font = Font.boldSystemFont(12);
  t.textColor = TEXT;
  h.addSpacer();
  const refresh = h.addText(new Date().toLocaleTimeString([], {hour:"2-digit", minute:"2-digit"}));
  refresh.font = Font.systemFont(10);
  refresh.textColor = SUBTLE;
}

function row(w, item){
  const s = w.addStack();
  s.layoutHorizontally();
  s.url = item.link;

  // bullet
  const dot = s.addText("•");
  dot.font = Font.boldSystemFont(13);
  dot.textColor = TEXT;
  s.addSpacer(6);

  // title
  const t = s.addText(item.title);
  t.font = Font.systemFont(13);
  t.textColor = TEXT;
  t.lineLimit = TITLE_LINE_LIMIT;

  if (SHOW_REL_TIME){
    s.addSpacer(6);
    const ago = s.addText(`· ${timeAgo(item.date)}`);
    ago.font = Font.systemFont(11);
    ago.textColor = SUBTLE;
  }
}

function makeWidget(items){
  const w = new ListWidget();
  const grad = new LinearGradient();
  grad.colors = [SKY, DEEP];
  grad.locations = [0, 1];
  grad.startPoint = new Point(0, 0);
  grad.endPoint = new Point(1, 1);
  w.backgroundGradient = grad;
  w.setPadding(10, 12, 10, 12);

  header(w);
  w.addSpacer(6);
  items.forEach((it, idx) => {
    row(w, it);
    if (idx < items.length-1) w.addSpacer(4);
  });

  return w;
}

async function run(){
  try{
    const xml = await fetchRSS(FEED_URL);
    const items = parseRSS(xml);
    const widget = makeWidget(items);
    if (config.runsInWidget) Script.setWidget(widget);
    else await widget.presentMedium();
  } catch (e){
    const w = new ListWidget();
    w.addText("SkyBlueTalk — error").font = Font.boldSystemFont(12);
    w.addText(String(e)).font = Font.systemFont(10);
    Script.setWidget(w);
  }
  Script.complete();
}
await run();
 
Reactions: M3rcian, duffer, Briles and 6 others

Evo1883

Well-Known Member
  • Monday at 9:07 AM
  • #2
 
Reactions: Calista, Houchens Head, Moff and 13 others

shmmeee

Well-Known Member
  • Monday at 9:08 AM
  • #3
Evo1883 said:
Click to expand...

Why not?
 
Reactions: ccfc1034

Grendel

Well-Known Member
  • Monday at 9:08 AM
  • #4
When I read the title I thought it was a commitment from you to not make any more idiotic posts
 
Reactions: bawtryneal, Sky Blue Pete, eastwoodsdustman and 11 others

Nick

Administrator
  • Monday at 9:12 AM
  • #5
Can you not just use an RSS reader app? It saves trying to scrape and you get the clean xml
 
S

SkyBluePower

Well-Known Member
  • Monday at 9:13 AM
  • #6
We can all get the benefit of your forensic insight on Brau now
 
D

djr8369

Well-Known Member
  • Monday at 9:16 AM
  • #7
ChatGPT actually managed that without so much debugging you basically had to write it yourself?
 
G

Gleneagles65

Well-Known Member
  • Monday at 9:16 AM
  • #8
This is going to catch on.
 
Reactions: Grendel

shmmeee

Well-Known Member
  • Monday at 9:21 AM
  • #9
Nick said:
Can you not just use an RSS reader app? It saves trying to scrape and you get the clean xml
Click to expand...

Ah maybe I can. Will have a look. The troubles with vibe coding.
 

shmmeee

Well-Known Member
  • Monday at 9:22 AM
  • #10
djr8369 said:
ChatGPT actually managed that without so much debugging you basically had to write it yourself?
Click to expand...

One shot ten seconds work. But as Nick points out not the best solution. So still very ChatGPT.
 

Nick

Administrator
  • Monday at 9:22 AM
  • #11
shmmeee said:
Ah maybe I can. Will have a look. The troubles with vibe coding.
Click to expand...
Should be able to get the RSS link for a certain forum

If it works though, it works
 

shmmeee

Well-Known Member
  • Monday at 9:23 AM
  • #12
Nick said:
Should be able to get the RSS link for a certain forum

If it works though, it works
Click to expand...

I didn’t even realise SBT had an rss feed. I didn’t even realise rss feeds were still a thing.
 

Nick

Administrator
  • Monday at 9:25 AM
  • #13
shmmeee said:
I didn’t even realise SBT had an rss feed. I didn’t even realise rss feeds were still a thing.
Click to expand...
Yeah that's what the code is looking at.
 

shmmeee

Well-Known Member
  • Monday at 9:26 AM
  • #14
Nick said:
Yeah that's what the code is looking at.
Click to expand...

I mean before I asked chat you nob
 
D

djr8369

Well-Known Member
  • Monday at 9:31 AM
  • #15
shmmeee said:
I didn’t even realise SBT had an rss feed. I didn’t even realise rss feeds were still a thing.
Click to expand...
Making a bit of a comeback as doesn’t have the pitfalls of social media.
 
Reactions: wingy
H

HuckerbyDublinWhelan

Well-Known Member
  • Monday at 9:34 AM
  • #16
Can this be stickied? I applaud the effort.
 

Gynnsthetonic

Well-Known Member
  • Monday at 9:35 AM
  • #17
Close thread please!
 

mrfr

Well-Known Member
  • Monday at 9:36 AM
  • #18
Thanks for boiling a lake on all of our behalf.
 
Reactions: Calista, Potbellypig, torchomatic and 6 others

skybluecam

Well-Known Member
  • Monday at 9:39 AM
  • #19
SkyBlueDom26 said:
Tuesday morning, not even 10am yet. One of the most embarrassing things I’ve ever witnessed! Seek help, I’m genuinely concerned
Click to expand...
Some life you’ve lived then

And it’s Monday
 
Reactions: Matt smith
W

wingy

Well-Known Member
  • Monday at 9:46 AM
  • #20
shmmeee said:
Why not?
Click to expand...
,x!
 

Mcbean

Well-Known Member
  • Monday at 9:54 AM
  • #21
Cov thread wankah
 

Captain Dart

Well-Known Member
  • Monday at 9:59 AM
  • #22
Nick said:
Can you not just use an RSS reader app? It saves trying to scrape and you get the clean xml
Click to expand...
 

MacReady

Well-Known Member
  • Monday at 10:04 AM
  • #23
 
Reactions: Calista

SBAndy

Well-Known Member
  • Monday at 10:17 AM
  • #24
Can you do one for Tony for the politics thread?
 
Reactions: Ccfcisparks

SBAndy

Well-Known Member
  • Monday at 10:18 AM
  • #25
Nick said:
Can you not just use an RSS reader app? It saves trying to scrape and you get the clean xml
Click to expand...

What is this? DM me about how to do it please.
 

Nick

Administrator
  • Monday at 10:25 AM
  • #26
You can get RSS reader apps and then just add the URL to get the latest posts into it
 
W

wingy

Well-Known Member
  • Monday at 10:31 AM
  • #27
What are we going to do with all this time we're saving?
 
Reactions: Calista and duffer

Skyblueweeman

Well-Known Member
  • Monday at 11:08 AM
  • #28
 
Reactions: Houchens Head and Captain Dart

Noble

Well-Known Member
  • Monday at 11:18 AM
  • #29
Quite liked the intent here and set up the RSS feed for notifications, just for some absolute whopper to post that we’d signed Hughes
 
Reactions: Captain Dart

Johhny Blue

Well-Known Member
  • Monday at 5:00 PM
  • #30
Half the time I can’t even send a text to the right person
 
Reactions: The Reverend Skyblue and wingy
G

Gleneagles65

Well-Known Member
  • Tuesday at 9:07 PM
  • #31
This has to be repeated for the next transfer window.
 
You must log in or register to reply here.

Users who are viewing this thread

Total: 3 (members: 0, guests: 3)
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email
  • Home
  • Forums
  • Coventry City Football Club
  • Coventry City General Chat
  • Default Style
  • Contact us
  • Terms and rules
  • Privacy policy
  • Help
  • Home
Community platform by XenForo® © 2010-2021 XenForo Ltd.
Menu
Log in

Register

  • Home
  • Forums
    • New posts
    • Search forums
  • What's new
    • New posts
    • Latest activity
  • Members
    • Current visitors
  • Donate to the Season Ticket Fund
X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?

X

Privacy & Transparency

We use cookies and similar technologies for the following purposes:

  • Personalized ads and content
  • Content measurement and audience insights

Do you accept cookies and these technologies?