Skip to content

Commit

Permalink
Add click event to scriptable
Browse files Browse the repository at this point in the history
  • Loading branch information
StringManolo committed Jul 20, 2024
1 parent 068f413 commit 9d8dbaf
Show file tree
Hide file tree
Showing 44 changed files with 167 additions and 44 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Panther/app/build/classes/com/stringmanolo/panther/R$id.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Panther/app/build/classes/com/stringmanolo/panther/R$style.class
Binary file not shown.
Binary file modified Panther/app/build/dexedClasses/classes.dex
Binary file not shown.
39 changes: 20 additions & 19 deletions Panther/app/build/generated/source/R.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,26 @@ int drawable ic_launcher 0x7f020005
int drawable panthera 0x7f020006
int drawable panthera2 0x7f020007
int drawable patair 0x7f020008
int id RectanguloMenuIcono 0x7f070006
int id buttonIr 0x7f07000b
int id buttonUA 0x7f070010
int id consoleInput 0x7f070004
int id consoleOutput 0x7f070003
int id executeButton 0x7f070005
int id favicon 0x7f070009
int id listView 0x7f070007
int id listaHacking 0x7f07000d
int id listaMotores 0x7f070011
int id logsOutput 0x7f070002
int id progressbar 0x7f07000c
int id scriptable 0x7f070000
int id textView 0x7f070008
int id textoHacking 0x7f07000e
int id textoMotores 0x7f070012
int id url 0x7f07000a
int id userAgent 0x7f07000f
int id webkit 0x7f070001
int id RectanguloMenuIcono 0x7f070007
int id buttonIr 0x7f07000c
int id buttonUA 0x7f070011
int id consoleInput 0x7f070005
int id consoleOutput 0x7f070004
int id executeButton 0x7f070006
int id favicon 0x7f07000a
int id listView 0x7f070008
int id listaHacking 0x7f07000e
int id listaMotores 0x7f070012
int id logsOutput 0x7f070003
int id progressbar 0x7f07000d
int id rootlayout 0x7f070000
int id scriptable 0x7f070001
int id textView 0x7f070009
int id textoHacking 0x7f07000f
int id textoMotores 0x7f070013
int id url 0x7f07000b
int id userAgent 0x7f070010
int id webkit 0x7f070002
int layout activity_main 0x7f030000
int layout layout_hacking 0x7f030001
int layout layout_motor_de_busqueda 0x7f030002
Expand Down
39 changes: 20 additions & 19 deletions Panther/app/build/generated/source/com/stringmanolo/panther/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,26 @@ public static final class drawable {
public static final int patair=0x7f020008;
}
public static final class id {
public static final int RectanguloMenuIcono=0x7f070006;
public static final int buttonIr=0x7f07000b;
public static final int buttonUA=0x7f070010;
public static final int consoleInput=0x7f070004;
public static final int consoleOutput=0x7f070003;
public static final int executeButton=0x7f070005;
public static final int favicon=0x7f070009;
public static final int listView=0x7f070007;
public static final int listaHacking=0x7f07000d;
public static final int listaMotores=0x7f070011;
public static final int logsOutput=0x7f070002;
public static final int progressbar=0x7f07000c;
public static final int scriptable=0x7f070000;
public static final int textView=0x7f070008;
public static final int textoHacking=0x7f07000e;
public static final int textoMotores=0x7f070012;
public static final int url=0x7f07000a;
public static final int userAgent=0x7f07000f;
public static final int webkit=0x7f070001;
public static final int RectanguloMenuIcono=0x7f070007;
public static final int buttonIr=0x7f07000c;
public static final int buttonUA=0x7f070011;
public static final int consoleInput=0x7f070005;
public static final int consoleOutput=0x7f070004;
public static final int executeButton=0x7f070006;
public static final int favicon=0x7f07000a;
public static final int listView=0x7f070008;
public static final int listaHacking=0x7f07000e;
public static final int listaMotores=0x7f070012;
public static final int logsOutput=0x7f070003;
public static final int progressbar=0x7f07000d;
public static final int rootlayout=0x7f070000;
public static final int scriptable=0x7f070001;
public static final int textView=0x7f070009;
public static final int textoHacking=0x7f07000f;
public static final int textoMotores=0x7f070013;
public static final int url=0x7f07000b;
public static final int userAgent=0x7f070010;
public static final int webkit=0x7f070002;
}
public static final class layout {
public static final int activity_main=0x7f030000;
Expand Down
Binary file modified Panther/app/build/output/app-debug.apk
Binary file not shown.
Binary file modified Panther/app/build/output/app-unsigned-debug.apk
Binary file not shown.
Binary file modified Panther/app/build/resources.ap_
Binary file not shown.
6 changes: 4 additions & 2 deletions Panther/app/src/main/assets/panther_scriptable.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h1>Panther Scriptable</h1>


<script>
/*
console.log("Starting connection to ws://127.0.0.1:13370 ... ");
const socket = new WebSocket("ws://localhost:13370");
Expand All @@ -38,7 +39,7 @@ <h1>Panther Scriptable</h1>
socket.addEventListener("error", function (event) {
console.error("WebSocket error: ", event);
});

*/

/* API */
const navigate = url => {
Expand All @@ -53,7 +54,8 @@ <h1>Panther Scriptable</h1>
/* SCRIPTS */
/* PROTONMAIL ACCOUNT */
const newProtonMailAccount = (username, password) => {
navigate("https://account.proton.me/mail/signup?plan=free&ref=mail_plus_intro-mailpricing-2&currency=EUR");
//navigate("https://account.proton.me/mail/signup?plan=free&ref=mail_plus_intro-mailpricing-2&currency=EUR");
navigate("https://www.google.com/search?q=cars");
}
document.querySelector("#npa").addEventListener("click", () => {
newProtonMailAccount("test", "test123");
Expand Down
111 changes: 109 additions & 2 deletions Panther/app/src/main/java/com/stringmanolo/panther/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@

import java.net.URL;
import android.webkit.JavascriptInterface;
import android.widget.RelativeLayout;

import android.view.MotionEvent;
import android.graphics.drawable.GradientDrawable;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;
import android.view.ViewTreeObserver;


public class MainActivity extends Activity {
Expand Down Expand Up @@ -264,7 +275,7 @@ public void onItemClick(AdapterView < ? > adapterView, View view, int position,
Scriptable.getSettings().setUserAgentString(userAgentModificado);
Scriptable.setWebViewClient(new WebViewClient());
Scriptable.setWebChromeClient(new WebChromeClient());
Panther.addJavascriptInterface(new SCRIPTABLE(), "scriptable");
Panther.addJavascriptInterface(new SCRIPTABLE(this), "scriptable");


consoleOutput.setText("Use the url #clearconsole to clear\n\n\n\n\n\n\n\n");
Expand Down Expand Up @@ -703,6 +714,15 @@ private String readStream(InputStream inputStream) throws IOException {

/* For Scriptable WebView */
public class SCRIPTABLE {
private MainActivity activity;


public SCRIPTABLE(MainActivity activity) {
this.activity = activity;
}



@JavascriptInterface
public boolean test() {
return true;
Expand All @@ -720,6 +740,93 @@ public void run() {
});
}

}
@JavascriptInterface
public void resize(final int x, final int y) {
final Handler scriptableHandler = new Handler(Looper.getMainLooper());
scriptableHandler.post(new Runnable() {
@Override
public void run() {
// logsOutput.append("+ Request for " + url + "\n");
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(x, y);
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

Scriptable.setLayoutParams(params);
}
});
}



@JavascriptInterface
public void click(final int x, final int y) {
final Handler scriptableHandler = new Handler(Looper.getMainLooper());
scriptableHandler.post(new Runnable() {
@Override
public void run() {

MotionEvent downEvent = MotionEvent.obtain(
System.currentTimeMillis(),
System.currentTimeMillis(),
MotionEvent.ACTION_DOWN,
x,
y,
0
);

MotionEvent upEvent = MotionEvent.obtain(
System.currentTimeMillis(),
System.currentTimeMillis(),
MotionEvent.ACTION_UP,
x,
y,
0
);

// Show in Scriptable where the click has been made
final View clickEffect = new View(activity);
GradientDrawable shape = new GradientDrawable();
shape.setShape(GradientDrawable.OVAL);
shape.setColor(0xFFFF0000); // red
shape.setSize(50, 50);
clickEffect.setBackground(shape);

// Center the circle
int clickX = x - 25;
int clickY = y - 25;

FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(50, 50);

clickEffect.setX(clickX);
clickEffect.setY(clickY);

//final RelativeLayout rootLayout = findViewById(R.id.rootlayout);
final WebView rootLayout = findViewById(R.id.scriptable);
rootLayout.addView(clickEffect, params);

// Remove the circle after 500ms
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
rootLayout.removeView(clickEffect);
}
}, 400);

// Send the actual click
Scriptable.dispatchTouchEvent(downEvent);
Scriptable.dispatchTouchEvent(upEvent);
}
});
}











}
}
15 changes: 13 additions & 2 deletions Panther/app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/barrabusquedaurl"
android:elevation="99dp"
>



<RelativeLayout
android:id="@+id/rootlayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
Expand All @@ -17,9 +19,8 @@
android:id="@+id/scriptable"
android:layout_width="200dp"
android:layout_height="400dp"
android:elevation="8dp"
android:elevation="2dp"
android:layout_centerInParent="true"
android:layout_marginTop="100dp"
/>


Expand All @@ -45,6 +46,7 @@
android:layout_alignParentBottom="true"
android:gravity="bottom|left"
android:textIsSelectable="true"
android:elevation="3dp"
/>

<TextView
Expand All @@ -61,6 +63,7 @@
android:layout_alignParentBottom="true"
android:gravity="bottom|left"
android:textIsSelectable="true"
android:elevation="4dp"
/>

<EditText
Expand All @@ -73,6 +76,7 @@
android:inputType="text"
android:layout_alignParentBottom="true"
android:layout_toLeftOf="@+id/executeButton"
android:elevation="4dp"
/>

<Button
Expand All @@ -83,6 +87,7 @@
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:elevation="4dp"
/>

<View
Expand All @@ -92,6 +97,7 @@
android:background="@drawable/fondo_menu_icono"
android:layout_marginTop="44dp"
android:layout_alignParentTop="true"
android:elevation="99dp"
/>

<ListView
Expand All @@ -100,6 +106,7 @@
android:layout_height="250dp"
android:layout_marginTop="44dp"
android:layout_alignParentTop="true"
android:elevation="99dp"
/>

<TextView
Expand All @@ -112,6 +119,7 @@
android:scrollbars="vertical"
android:layout_marginTop="44dp"
android:layout_alignParentTop="true"
android:elevation="99dp"
/>

<ImageView
Expand All @@ -124,6 +132,7 @@
android:layout_alignParentTop="true"
android:onClick="Config"
android:src="@drawable/panthera2"
android:elevation="99dp"
/>

<EditText
Expand All @@ -138,6 +147,7 @@
android:layout_marginTop="4dp"
android:inputType="textUri"
android:selectAllOnFocus="true"
android:elevation="99dp"
/>

<Button
Expand All @@ -149,6 +159,7 @@
android:layout_alignParentRight="true"
android:text="@string/ir"
android:onClick="ir"
android:elevation="99dp"
/>

</RelativeLayout>
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
- Allow to change default webpage
- Add new privacy overrides (like battery status) This seems very hard to do.
- Allow to use System's Tor Proxy
- Activate Interface only when Scriptable is visiable

0 comments on commit 9d8dbaf

Please sign in to comment.