Skip to content

Instantly share code, notes, and snippets.

View cypressious's full-sized avatar
🤖
beep bop

Kirill Rakhman cypressious

🤖
beep bop
View GitHub Profile
fun main(args: Array<String>) {
if (window.asDynamic().hasRun == true) {
return
}
window.asDynamic().hasRun = true
browser.runtime.onMessage.addListener { message ->
if (message.command === "beastify") {
insertBeast(message.beastURL as String)
} else if (message.command === "reset") {
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="choose_beast.css"/>
</head>
<body>
<div id="popup-content">
<div class="button beast">Frog</div>
external val browser: Browser
external class Browser {
val tabs: Tabs
}
external class Tabs {
fun executeScript(def: Script): Promise<List<Any>>
}
fun listenForClicks() {
document.addEventListener("click", { e ->
val target = e.target as? Element ?: return@addEventListener
browser.tabs.query(Query(active = true, currentWindow = true))
.then({ tabs -> handleClick(target, tabs[0].id) })
.catch(::reportError)
})
}
@cypressious
cypressious / build.gradle
Created December 22, 2016 11:09
Gradle Script to wait for Emulator to boot (Android)
task waitForEmulator << {
def start = System.currentTimeMillis()
while (System.currentTimeMillis() - start < 60000) {
def out = new StringBuilder()
def process = 'adb shell getprop init.svc.bootanim'.execute()
process.consumeProcessOutput(out, null)
process.waitForOrKill(1000)
if (out.toString().trim() == "stopped") return