This file contains hidden or 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
| 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") { |
This file contains hidden or 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
| external val browser: Browser | |
| external class Browser { | |
| val tabs: Tabs | |
| } | |
| external class Tabs { | |
| fun executeScript(def: Script): Promise<List<Any>> | |
| } |
This file contains hidden or 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 val SCRIPT_PATH = "/content_script/build/classes/kotlin/main/min" | |
| fun main(args: Array<String>) { | |
| Promise.all(arrayOf( | |
| browser.tabs.executeScript(Script("$SCRIPT_PATH/kotlin.js")), | |
| browser.tabs.executeScript(Script("$SCRIPT_PATH/content_script.js")) | |
| )) | |
| .then({ listenForClicks() }) | |
| .catch(::reportExecuteScriptError) | |
| } |
This file contains hidden or 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
| 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) | |
| }) | |
| } |
This file contains hidden or 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
| { | |
| "manifest_version": 2, | |
| "name": "Beastify", | |
| "version": "1.0", | |
| "permissions": [ | |
| "activeTab" | |
| ], | |
| "browser_action": { | |
| "default_icon": "icons/beasts-32.png", |
This file contains hidden or 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
| <!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> |
This file contains hidden or 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
| buildscript { | |
| ext.kotlin_version = '1.1.60' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | |
| } | |
| } |
This file contains hidden or 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
| version '1.0-SNAPSHOT' | |
| buildscript { | |
| ext.kotlin_version = '1.1.60' | |
| repositories { | |
| mavenCentral() | |
| } | |
| dependencies { | |
| classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| val mutex = Semaphore(0) | |
| val source = Observable.interval(200, TimeUnit.MILLISECONDS).take(10) | |
| val delayed = source.delayUntil(3L) | |
| println("${System.currentTimeMillis()}: start") | |
| delayed.subscribe( | |
| { println("${System.currentTimeMillis()}: $it") }, | |
| { println("Failed with $it") }, | |
| { mutex.release() } | |
| ) |
NewerOlder