Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// 𝗢𝗳𝗳𝗶𝗰𝗶𝗮𝗹 𝗖𝗿𝗲𝗮𝘁𝗼𝗿 @SHEV IOS.
// icon-color: purple; icon-glyph: power-off;
// Variables used by Scriptable.
// They must be at the top of the file. Do not edit.
// Game Version
let gameName = "Free Fire"
let gameVersion = "V6"
// Background Color
let widget = new ListWidget();
let title = widget.addText("𝐒𝐇𝐄𝐕 𝐈𝐎𝐒 ");
widget.backgroundColor = new Color("#000600");
title.textColor = Color.purple();
widget.addSpacer();
// Create stack for old functions
let stack1 = widget.addStack();
stack1.layoutHorizontally();
stack1.addSpacer();
let headtrackingText = stack1.addText("𝗛𝗘𝗔𝗗𝗧𝗥𝗔𝗖𝗞𝗜𝗡𝗚
// Function:𝗛𝗘𝗔𝗗𝗧𝗥𝗔𝗖𝗞𝗜𝗡𝗚
");
headtrackingText.textColor = Color.white();
stack1.addSpacer();
widget.addSpacer();
// Create stack for new functions
let stack2 = widget.addStack();
stack2.layoutHorizontally();
stack2.addSpacer();
stack2.addSpacer();
widget.addSpacer();
// 𝗩𝗲𝗿𝘀𝗶𝗼𝗻
let Text = widget.addText("𝐕𝐄𝐑𝐒𝐈𝐎𝐍 𝐕𝟔");
Text.textColor = Color.purple();
Text.rightAlignText();
//
if (config.runsInWidget) {
Script.setWidget(widget);
} else {
widget.presentMedium();
}
Script.complete();
// Game optimization function
function gameOptimization() {
// Turn off reminder notifications
disableNotifications();
// Disable unnecessary features
disableFeatures();
}
// Function to turn off notifications and reminders
function disableNotifications() {
// Use the API provided by Scriptable to disable notifications
// code here
}
// Function to disable unnecessary features
function disableFeatures() {
// Use API provided by Scriptable to disable unnecessary features
// code here
}
// Add Headtracking on iOS devices
addHeadtracking();
// Function(body) Adds Headtracking
function addHeadtracking() {
// Tweak values
const headtracking = 100.0;
} // Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-blue; icon-glyph: book;
// This script shows a random Scriptable API in a widget. The script is meant to be
used with a widget configured on the Home Screen.
// You can run the script in the app to preview the widget or you can go to the
Home Screen, add a new Scriptable widget and configure the widget to run this
script.
// You can also try creating a shortcut that runs this script. Running the shortcut
will show widget.
let api = await randomAPI()
let widget = await createWidget(api)
if (config.runsInWidget) {
// The script runs inside a widget, so we pass our instance of ListWidget to be
shown inside the widget on the Home Screen.
Script.setWidget(widget)
} else {
// The script runs inside the app, so we preview the widget.
widget.presentMedium()
}
// Calling Script.complete() signals to Scriptable that the script have finished
running.
// This can speed up the execution, in particular when running the script from
Shortcuts or using Siri.
Script.complete()
async function createWidget(api) {
let appIcon = await loadAppIcon()
let title = "Random Scriptable API"
let widget = new ListWidget()
// Add background gradient
let gradient = new LinearGradient()
gradient.locations = [0, 1]
gradient.colors = [
new Color("141414"),
new Color("13233F")
]
widget.backgroundGradient = gradient
// Show app icon and title
let titleStack = widget.addStack()
let appIconElement = titleStack.addImage(appIcon)
appIconElement.imageSize = new Size(15, 15)
appIconElement.cornerRadius = 4
titleStack.addSpacer(4)
let titleElement = titleStack.addText(title)
titleElement.textColor = Color.white()
titleElement.textOpacity = 0.7
titleElement.font = Font.mediumSystemFont(13)
widget.addSpacer(12)
// Show API
let nameElement = widget.addText(api.name)
nameElement.textColor = Color.white()
nameElement.font = Font.boldSystemFont(18)
widget.addSpacer(2)
let descriptionElement = widget.addText(api.description)
descriptionElement.minimumScaleFactor = 0.5
descriptionElement.textColor = Color.white()
descriptionElement.font = Font.systemFont(18)
// UI presented in Siri ans Shortcuta is non-interactive, so we only show the
footer when not running the script from Siri.
if (!config.runsWithSiri) {
widget.addSpacer(8)
// Add button to open documentation
let linkSymbol = SFSymbol.named("arrow.up.forward")
let footerStack = widget.addStack()
let linkStack = footerStack.addStack()
linkStack.centerAlignContent()
linkStack.url = api.url
let linkElement = linkStack.addText("Read more")
linkElement.font = Font.mediumSystemFont(13)
linkElement.textColor = Color.blue()
linkStack.addSpacer(3)
let linkSymbolElement = linkStack.addImage(linkSymbol.image)
linkSymbolElement.imageSize = new Size(11, 11)
linkSymbolElement.tintColor = Color.blue()
footerStack.addSpacer()
// Add link to documentation
let docsSymbol = SFSymbol.named("book")
let docsElement = footerStack.addImage(docsSymbol.image)
docsElement.imageSize = new Size(20, 20)
docsElement.tintColor = Color.white()
docsElement.imageOpacity = 0.5
docsElement.url = "https://docs.scriptable.app"
}
return widget
}
async function randomAPI() {
let docs = await loadDocs()
let apiNames = Object.keys(docs)
let num = Math.round(Math.random() * apiNames.length)
let apiName = apiNames[num]
let api = docs[apiName]
return {
name: apiName,
description: api["!doc"],
url: api["!url"]
}
}
async function loadDocs() {
let url = "https://docs.scriptable.app/scriptable.json"
let req = new Request(url)
return await req.loadJSON()
}
async function loadAppIcon() {
let url =
"https://is5-ssl.mzstatic.com/image/thumb/Purple124/v4/21/1e/13/211e13de-2e74-4221-
f7db-d6d2c53b4323/AppIcon-1x_U007emarketing-0-7-0-85-220.png/540x540sr.jpg"
let req = new Request(url)
return req.loadImage()
} // Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: red; icon-glyph: newspaper;
// This script shows articles from MacStories. The script can be used either in the
app, as a widget on your Home Screen or through Shortcuts. The behaviour of the
script will vary slightly depending on where it's used.
let items = await loadItems()
if (config.runsInWidget) {
// Tell the widget on the Home Screen to show our ListWidget instance.
let widget = await createWidget(items)
Script.setWidget(widget)
} else if (config.runsWithSiri) {
// Present a table with a subset of the news.
let firstItems = items.slice(0, 5)
let table = createTable(firstItems)
await QuickLook.present(table)
} else {
// Present the full list of news.
let table = createTable(items)
await QuickLook.present(table)
}
// Calling Script.complete() signals to Scriptable that the script have finished
running.
// This can speed up the execution, in particular when running the script from
Shortcuts or using Siri.
Script.complete()
async function createWidget(items) {
let item = items[0]
let authors = item.authors.map(a => {
return a.name
}).join(", ")
let imgURL = extractImageURL(item)
let rawDate = item["date_published"]
let date = new Date(Date.parse(rawDate))
let dateFormatter = new DateFormatter()
dateFormatter.useMediumDateStyle()
dateFormatter.useShortTimeStyle()
let strDate = dateFormatter.string(date)
let gradient = new LinearGradient()
gradient.locations = [0, 1]
gradient.colors = [
new Color("#b00a0fe6"),
new Color("#b00a0fb3")
]
let widget = new ListWidget()
if (imgURL != null) {
let imgReq = new Request(imgURL)
let img = await imgReq.loadImage()
widget.backgroundImage = img
}
widget.backgroundColor = new Color("#b00a0f")
widget.backgroundGradient = gradient
// Add spacer above content to center it vertically.
widget.addSpacer()
// Show article headline.
let title = decode(item.title)
let titleElement = widget.addText(title)
titleElement.font = Font.boldSystemFont(16)
titleElement.textColor = Color.white()
titleElement.minimumScaleFactor = 0.75
// Add spacing below headline.
widget.addSpacer(8)
// Add footer woth authors and date.
let footerStack = widget.addStack()
let authorsElement = footerStack.addText(authors)
authorsElement.font = Font.mediumSystemFont(12)
authorsElement.textColor = Color.white()
authorsElement.textOpacity = 0.9
footerStack.addSpacer()
let dateElement = footerStack.addText(strDate)
dateElement.font = Font.mediumSystemFont(12)
dateElement.textColor = Color.white()
dateElement.textOpacity = 0.9
// Add spacing below content to center it vertically.
widget.addSpacer()
// Set URL to open when tapping widget.
widget.url = item.url
return widget
}
function createTable(items) {
let table = new UITable()
for (item of items) {
let row = new UITableRow()
let imageURL = extractImageURL(item)
let title = decode(item.title)
let imageCell = row.addImageAtURL(imageURL)
let titleCell = row.addText(title)
imageCell.widthWeight = 20
titleCell.widthWeight = 80
row.height = 60
row.cellSpacing = 10
row.onSelect = (idx) => {
let item = items[idx]
Safari.open(item.url)
}
row.dismissOnSelect = false
table.addRow(row)
}
return table
}
async function loadItems() {
let url = "https://macstories.net/feed/json"
let req = new Request(url)
let json = await req.loadJSON()
return json.items
}
function extractImageURL(item) {
let regex = /<img src="(.*)" alt="/
let html = item["content_html"]
let matches = html.match(regex)
if (matches && matches.length >= 2) {
return matches[1]
} else {
return null
}
}
function decode(str) {
let regex = /&#(\d+);/g
return str.replace(regex, (match, dec) => {
return String.fromCharCode(dec)
})
}