From 20b960c5fde7a2d06ebbc6f6b2d7c9c87aaf6421 Mon Sep 17 00:00:00 2001
From: yuan cesar <1052481067@qq.com>
Date: Tue, 15 Dec 2020 17:00:20 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +
main.js | 175 +++++++++++++++++++++++++++++++++++++++++++++++++++
project.json | 29 +++++++++
res/logo.png | Bin 0 -> 5423 bytes
4 files changed, 206 insertions(+)
create mode 100644 README.md
create mode 100644 main.js
create mode 100644 project.json
create mode 100644 res/logo.png
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..85f6067
--- /dev/null
+++ b/README.md
@@ -0,0 +1,2 @@
+# NotificationToQuicker
+转发手机通知到Quicker
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..5348874
--- /dev/null
+++ b/main.js
@@ -0,0 +1,175 @@
+"ui";
+//auto();
+config = storages.create("quicker-notification");
+var email = config.get("email", "");
+var actionId = config.get("actionId", "");
+var code = config.get("code", "");
+var filterWords = config.get("filterWords", ["^.{2,3}输入法$", "^后台采集服务", "Bytes/s", "KiB/s"]);
+//runObserve(email, actionId, code)
+initUI();
+//loop();
+
+function runObserve(email, actionId, code){
+ events.observeNotification();
+ events.onNotification(function (notification) {
+ var packageName = notification.getPackageName();
+ var title = notification.getTitle();
+ var text = notification.getText();
+ if(!inBlackList(text, filterWords)){
+ var data = "手机通知:" + [packageName, title, text].join("---");
+ // if (notification.getText().match(/验证码|([^\d]|^)\d{6}(?!\d)/)) {
+ // log("检测到验证码,准备发送")
+ var json = {
+ "toUser": email,
+ "code": code,
+ "data": data,
+ "operation": "action",
+ "action": actionId
+ }
+ var r = http.postJson("https://push.getquicker.net/push", json, {}, function (response) {
+ log(response.body.json());
+ var returnJson = response.body.json();
+ if(returnJson.successCount === 0){
+ toast(returnJson.errorMessage);
+ }
+ });
+ // }
+ console.log(data);
+ }
+ });
+}
+
+function initUI(){
+ ui.layout(
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ ui.email.setText(email);
+ ui.actionId.setText(actionId);
+ ui.code.setText(code);
+ ui.filterWords.setText(filterWords.join('|||'));
+ //指定确定按钮点击时要执行的动作
+ ui.start.click(function(){
+ //通过getText()获取输入的内容
+ toast("准备检查输入的准确性");
+ updateConfig();
+ config.put("filterWords", filterWords);
+ if(checkConfig(email, actionId, code)){
+ toast("输入正确,连接成功,开始监控");
+ $ui.status.setText("状态:已开始");
+ config.put("email", email);
+ config.put("actionId", actionId);
+ config.put("code", code);
+ runObserve(email, actionId, code)
+ setTimeout(toHome, 500)
+ }
+ else{
+ toast("连接失败");
+ }
+ });
+ ui.stop.click(function(){
+ updateConfig();
+ config.put("filterWords", filterWords);
+ toast("已关闭");
+ exit();
+ });
+ // 点击返回回到桌面,不退出程序
+ ui.emitter.on("back_pressed", function (e) {
+ e.consumed = true;
+ toHome();
+ });
+ ui.showHelp.click(function(){
+ app.openUrl("https://getquicker.net/sharedaction?code=b40f77ff-42f7-4fe4-a1f5-08d89ff18571");
+ });
+ ui.author.click(function(){
+ app.openUrl("https://getquicker.net/User/18359/Cesaryuan");
+ });
+}
+
+function checkConfig(email, actionId, code){
+ var r = http.get("https://push.getquicker.net/helpers/getdevices?user=" + encodeURIComponent(email) + "&code=" + code);
+ try{
+ var returnJson = r.body.json();
+ if(returnJson.isSuccess){
+ return true;
+ }else{
+ log(returnJson);
+ toast(returnJson.message);
+ }
+
+ }
+ catch(e){
+ return false;
+ }
+}
+
+function registerEvent(){
+ //启用按键监听
+ events.observeKey();
+ //监听音量上键按下
+ events.onKeyDown("volume_up", function(event){
+ toast("音量上键被按下了");
+ });
+ //监听菜单键按下
+ events.onKeyDown("menu", function(event){
+ toast("菜单键被按下了");
+ exit();
+ });
+ events.on("exit", function(){
+ log("脚本已结束运行");
+ });
+
+}
+
+function toHome(){
+ var i = app.intent({
+ action: Intent.ACTION_MAIN,
+ category: Intent.CATEGORY_HOME,
+ flags: ["ACTIVITY_NEW_TASK"],
+ });
+ app.startActivity(i);
+}
+
+function inBlackList(text, words){
+ var bool = false;
+ for(word of words){
+ try{
+ if(text.match(word)){
+ bool = true;
+ }
+ }
+ catch(e){
+ log(e);
+ if(text.includes(word)){
+ bool = true;
+ }
+ }
+
+ }
+ return bool;
+}
+
+function updateConfig(){
+ email = ui.email.getText().toString();
+ actionId = ui.actionId.getText().toString();
+ code = ui.code.getText().toString();
+ filterWords = ui.filterWords.getText().toString().split('|||');
+}
\ No newline at end of file
diff --git a/project.json b/project.json
new file mode 100644
index 0000000..39ff809
--- /dev/null
+++ b/project.json
@@ -0,0 +1,29 @@
+{
+ "assets": [],
+ "build": {
+ "build_number": 0,
+ "build_time": 0,
+ "release": false
+ },
+ "encryptLevel": 0,
+ "useFeatures": [],
+ "icon": "res/logo.png",
+ "launchConfig": {
+ "displaySplash": true,
+ "hideLogs": true,
+ "splashText": "手机通知转发到Quicker",
+ "stableMode": true,
+ "splashIcon": "res/logo.png"
+ },
+ "main": "main.js",
+ "name": "发送通知",
+ "optimization": {
+ "removeOpenCv": true,
+ "unusedResources": true
+ },
+ "packageName": "com.cesaryuan.notification",
+ "scripts": {},
+ "versionCode": 1,
+ "versionName": "1.0.0"
+ }
+
\ No newline at end of file
diff --git a/res/logo.png b/res/logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..d865f600b482f1ec61e9ef10b6670304847f0192
GIT binary patch
literal 5423
zcmeHLX;hO}x5ld6sV3O9t9JL{Gb7Q(zK+fT94+C2{#q_q{LF74bZpXvU+s?gy|8m%GDyzLC{$O>e(rBQgilq)RrS?BPj>5%ph
zFF)u81_SK=`B!?(qMsXB6UtTd!*gZ~1>d%LxY}-jlv-0OTgTuPdNMrt;DgZ1pWP(k
z{e9Efw)c#VmVczf#kl6wk&*ZXY2o1D)b=&|0FU89sJK#rWc(DCa<)br>1gIWELL9v
zJ)$&}T1{YNlQeLu0!LFnF~e%@v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