title | description |
---|---|
Surge script for fetching financebe news |
m.fbecn.com provides a high quality and wider covering news feed. Use surge on iOS to fetch the feed every minute and post notifications.
- Reverse API request
- Build request from Surge
- Format the output
- Reverse API request with chrome. 2 params:
newsid
: cursor, set to 0 since retreive every minute.vs
: timestamp/6000, reversed from js on homepage.
- Surge API:
$httpClient.get(url, (error, response, data)=>{}
,$notification.post(title, subtitle, body)
$persistentStore.read()/write()
to store last round latest news.
- Split string with
】
to get title and body, format with★
if news is important.
Date.parse()
andDate()
implementation is different in every browser, raw date string fetched cannot be parsed in Surge JSVM, but can be handled in chrome. AddedT
between date and time to build ISO-like timestring and to parse correctly.$persistentStore
only support strings, key is string instead of list of strings. call write func withwrite(value, key)
- If title too long, iOS notification won't show full content. moved title to body to avoid loss of info.
- No need to transform CST to UTC, since cannot set notification time, get CST time from substring instead.
- Array.filter(item=>callback) to filter elements with conditions.
- Array.map(item=>callback) to deal with each item.