Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
An iPhone widget, that shows you a live webcam image from foto-webcam.eu on your homescreen
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: blue; icon-glyph: camera-retro;
// Script by Andreas Redeker <hello@andreasredeker.de>
let param = args.widgetParameter
let url
if (param != null && param.length > 0) {
url = param
} else {
url = "https://www.foto-webcam.eu/webcam/zugspitze-sued/"
}
const imgUrl = url + "current/400.jpg"
const imgReq = await new Request(imgUrl)
const img = await imgReq.loadImage()
if (config.runsInWidget) {
let widget = createWidget(img)
Script.setWidget(widget)
Script.complete()
} else {
let widget = createWidget(img)
await widget.presentMedium()
}
function createWidget(img) {
const widget = new ListWidget()
widget.backgroundColor = Color.black()
widget.url = url
widget.backgroundImage = img
widget.addSpacer()
const titleText = widget.addText(getWcNameFromUrl())
titleText.font = Font.boldSystemFont(12)
titleText.textColor = Color.white()
titleText.shadowRadius = 3
titleText.shadowColor = Color.black()
widget.addSpacer(2)
const subtitleText = widget.addText('foto-webcam.eu')
subtitleText.font = Font.systemFont(8)
subtitleText.textColor = Color.white()
subtitleText.textOpacity = 0.8
subtitleText.shadowRadius = 3
subtitleText.shadowColor = Color.black()
return widget
}
function getWcNameFromUrl() {
let wcName = url.split('/')
wcName = wcName[wcName.length - 2].replace('-', ' ').replace(/\b\w/g, function(c) {
return c.toUpperCase();
})
return wcName
}
@andreasRedeker

This comment has been minimized.

Copy link
Owner Author

@andreasRedeker andreasRedeker commented Nov 12, 2020

Webcam Widget

View your favorite webcam from foto-webcam.eu live on your iPhone homescreen!

57EDAD1F-71EA-4693-87B7-70B0BDC10ED6

Get Started

  1. Install the Scriptable App
  2. Copy the whole script from above
  3. Open the Scriptable App and tap „+“ in the upper right corner
  4. Paste the script, tap on "Untitled Script" on the top and type in "Webcam", then tap „Done“ in the upper left corner
  5. Go to your homescreen and long press to add a new widget
  6. Select the Scriptable widget and choose the medium-sized widget (the widget looks best in medium size)
  7. Go to foto-webcam.eu, tap on a webcam and copy the link from Safari
    make sure the link looks like this: https://www.foto-webcam.eu/webcam/zugspitze-sued/
    and not something like this: https://www.foto-webcam.eu/webcam/zugspitze-sued/2020/11/11/0730
  8. Now long press on the widget, tap „Edit Widget“, and select the „Webcam“ Script, paste the copied link into „Params“ and close the settings
  9. Finally you should see your selected webcam on your homescreen

Additional Info

  • Images are copyrighted by foto-webcam.eu
  • Your mobile data usage may increase. One image is about 120kb, which sums up to several MB each day, if you don’t always have a wifi connection
  • Widget loads a new webcam image about every 10 to 20 minutes (when the screen is on and the widget is visible). This is controlled by iOS and can not be changed

More

Fuel Price Widget ⛽️🇩🇪

IMG_1756 (1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment