Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //This is meant for a small widget
- //Preview will not work with displaying colours but the widget will have the colours
- //You can change the bellow
- //Enter hex colours in double quotes for the colours. The light colour will be active if light mode is on and the dark colour will be active if dark mode is on.
- //Enter your player tag below without the # but still in double quotes. There is currently a random tag I entered so it will not work
- //Enter number for minuetsAfterRefresh
- let player = "HID46D"
- let backgroundColourDark = "#000"
- let backgroundColourLight = "#fff"
- let textColourDark = "#fff"
- let textColourLight = "#000"
- let minuetsAfterRefresh = 10
- //Do Not Change
- let backgroundColour = Color.dynamic(new Color(backgroundColourLight),new Color(backgroundColourDark))
- let textColour = Color.dynamic(new Color(textColourLight),new Color(textColourDark))
- let url = "https://royaleapi.com/player/" + player
- let req = new Request(url)
- let html = await req.loadString()
- let chests = html.split('<h3 class="ui header">')[1]
- let plus1 = chests.split('" alt="')[0]
- plus1 = plus1.split('<img class="ui image" src="')[1]
- req = new Request(plus1)
- plus1 = await req.loadImage()
- let plus2 = chests.split('" alt="')[1]
- plus2 = plus2.split('<img class="ui image" src="')[1]
- let gientChest = chests.split('<img class="ui image" src="https://cdn.royaleapi.com/static/img/chests/chest-giant.png?t=695667cec" alt="Giant Chest" />')[1]
- gientChest = gientChest.split('<div class="top right attached circular ui basic label">+ ')[1]
- gientChest = gientChest.split('</div>')[0]
- let megaLightningChest = chests.split('<img class="ui image" src="https://cdn.royaleapi.com/static/img/chests/chest-megalightning.png?t=a6ec47cfc" alt="Mega Lightning Chest" />')[1]
- megaLightningChest = megaLightningChest.split('<div class="top right attached circular ui basic label">+ ')[1]
- megaLightningChest = megaLightningChest.split('</div>')[0]
- let magicalChest = chests.split('<img class="ui image" src="https://cdn.royaleapi.com/static/img/chests/chest-magical.png?t=0ed9f582c" alt="Magical Chest" />')[1]
- magicalChest = magicalChest.split('<div class="top right attached circular ui basic label">+ ')[1]
- magicalChest = magicalChest.split('</div>')[0]
- let legendaryChest = chests.split('<img class="ui image" src="https://cdn.royaleapi.com/static/img/chests/chest-legendary.png?t=9ef4bb1bc" alt="Legendary Chest" />')[1]
- legendaryChest = legendaryChest.split('<div class="top right attached circular ui basic label">+ ')[1]
- legendaryChest = legendaryChest.split('</div>')[0]
- let epicChest = chests.split('<img class="ui image" src="https://cdn.royaleapi.com/static/img/chests/chest-epic.png?t=741b36a8c" alt="Epic Chest" />')[1]
- epicChest = epicChest.split('<div class="top right attached circular ui basic label">+ ')[1]
- epicChest = epicChest.split('</div>')[0]
- let widget = new ListWidget()
- widget.backgroundColor = backgroundColour
- let date = new Date()
- date.setMinutes(date.getMinutes() + minuetsAfterRefresh)
- widget.refreshAfterDate = date
- let mainImage = widget.addImage(plus1)
- mainImage.centerAlignImage()
- mainImage.imageSize = new Size(50, 50)
- req = new Request(plus2)
- plus2 = await req.loadImage()
- addChest("2", plus2)
- req = new Request("https://cdn.royaleapi.com/static/img/chests/chest-giant.png")
- img = await req.loadImage()
- addChest(gientChest, img)
- req = new Request("https://cdn.royaleapi.com/static/img/chests/chest-magical.png")
- img = await req.loadImage()
- addChest(magicalChest, img)
- req = new Request("https://cdn.royaleapi.com/static/img/chests/chest-epic.png")
- img = await req.loadImage()
- addChest(epicChest, img)
- req = new Request("https://cdn.royaleapi.com/static/img/chests/chest-legendary.png")
- img = await req.loadImage()
- addChest(legendaryChest, img)
- req = new Request("https://cdn.royaleapi.com/static/img/chests/chest-megalightning.png")
- img = await req.loadImage()
- addChest(megaLightningChest, img)
- widget.presentSmall()
- Script.setWidget(widget)
- Script.complete()
- function addChest(text, img) {
- let stack = widget.addStack()
- stack.layoutHorizontally()
- img = stack.addImage(img)
- img.imageSize = new Size(15, 15)
- stack.addSpacer(20)
- text = stack.addText("+ " + text)
- text.textColor = textColour
- text.font = Font.mediumRoundedSystemFont(9)
- }
Advertisement
Add Comment
Please, Sign In to add comment