mirror of
https://github.com/SnapEnhance/scripting-docs.git
synced 2026-08-31 04:32:30 +00:00
feat: examples
This commit is contained in:
32
examples/disable_camera.js
Normal file
32
examples/disable_camera.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// ==SE_module==
|
||||
// name: Camera Disabler
|
||||
// version: 1.0
|
||||
// author: John Doe
|
||||
// ==/SE_module==
|
||||
|
||||
var hooker = require("hooker")
|
||||
var im = require("interface-manager")
|
||||
var config = require("config")
|
||||
|
||||
module.onSnapEnhanceLoad = context => {
|
||||
im.create("settings", builder => {
|
||||
builder.row(builder => {
|
||||
builder.text("Disable camera")
|
||||
builder.switch(config.getBoolean("disableCamera", false), value => {
|
||||
config.setBoolean("disableCamera", value, true)
|
||||
})
|
||||
}).spacedBy(10).fillMaxWidth()
|
||||
})
|
||||
}
|
||||
|
||||
module.onSnapMainActivityCreate = activity => {
|
||||
var getCameraDisabledMethod = hooker.findMethodWithParameters("android.app.admin.DevicePolicyManager", "getCameraDisabled", ["android.content.ComponentName"])
|
||||
|
||||
hooker.hook(getCameraDisabledMethod, hooker.stage.BEFORE, param => {
|
||||
if (!config.getBoolean("disableCamera", false)) {
|
||||
return
|
||||
}
|
||||
logInfo("getCameraDisabled called!")
|
||||
param.result = true
|
||||
})
|
||||
}
|
||||
17
examples/simple_ipc.js
Normal file
17
examples/simple_ipc.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// ==SE_module==
|
||||
// name: IPC Test
|
||||
// version: 1.0
|
||||
// author: John Doe
|
||||
// ==/SE_module==
|
||||
|
||||
var ipc = require("ipc")
|
||||
|
||||
module.onSnapEnhanceLoad = context => {
|
||||
ipc.on("myEvent", (args) => {
|
||||
longToast("received event: " + args)
|
||||
})
|
||||
}
|
||||
|
||||
module.onSnapMainActivityCreate = activity => {
|
||||
ipc.emit("myEvent", "hello", 255, activity.packageName)
|
||||
}
|
||||
22
examples/toast.js
Normal file
22
examples/toast.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// ==SE_module==
|
||||
// name: Toasts
|
||||
// description: Shows various toast messages
|
||||
// version: 1.0
|
||||
// author: John Doe
|
||||
// ==/SE_module==
|
||||
|
||||
module.onSnapMainActivityCreate = activity => {
|
||||
shortToast("Snapchat opened!")
|
||||
}
|
||||
|
||||
module.onSnapApplicationLoad = context => {
|
||||
shortToast("Snapchat loaded!")
|
||||
}
|
||||
|
||||
module.onSnapEnhanceLoad = context => {
|
||||
shortToast("SnapEnhance loaded!")
|
||||
}
|
||||
|
||||
module.onUnload = () => {
|
||||
shortToast("Script unloaded!")
|
||||
}
|
||||
Reference in New Issue
Block a user