Dhdhshsbsbd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Showing random wikimedia-commons-featured-picture | |
const url = `https://randomincategory.toolforge.org/Featured_pictures_on_Wikimedia_Commons?server=commons.wikimedia.org&type=file&debug=1` | |
const req = new Request(url) | |
const res = await req.loadString() | |
let titleRegExp = new RegExp("Location: https://commons.wikimedia.org/wiki/(.*)") | |
let titleMatch = res.match(titleRegExp) | |
let title = titleMatch[1].replace("<br>", ""); | |
let titleEncoded = encodeURI(title) | |
let url2 = `https://commons.wikimedia.org/w/api.php?action=query&titles=${titleEncoded}&prop=pageimages&format=json&pithumbsize=500` | |
const req2 = new Request(url2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const lang = "en" //use the language of your choice "en", "de", "it", "fr", etc. | |
const url = `https://${lang}.wikipedia.org/api/rest_v1/page/random/summary` | |
const req = new Request(url) | |
const res = await req.loadJSON() | |
const i = new Request(res.thumbnail.source); | |
const img = await i.loadImage(); | |
let widget = createWidget(res.title, img, res.content_urls.mobile.page) | |
if (config.runsInWidget) { | |
// create and show widget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Fetches Random Images from the metmuseum-api ; Stores the ids in the keychain in order to prevent multiple calls | |
//Department ID = 11 is paintings ; use other if you wish | |
var keychainkey = "paintingIDs" | |
var res | |
if(!Keychain.contains(keychainkey)) { | |
console.log("Keychainentry does not exist... create it"); | |
const url = 'https://collectionapi.metmuseum.org/public/collection/v1/search?hasImages=true&medium=Paintings&departmentId=11&q=Painting' | |
const req = new Request(url) | |
res = await req.loadJSON() | |
let stringified = JSON.stringify(res) |