webviewsextractor

Android WebViews Javascript file injection

License

License

Categories

Categories

Net
GroupId

GroupId

net.neferett
ArtifactId

ArtifactId

webviewsextractor
Last Version

Last Version

2.1.7
Release Date

Release Date

Type

Type

aar
Description

Description

webviewsextractor
Android WebViews Javascript file injection
Project URL

Project URL

https://github.com/jordanbonaldi/WebViewsExtractor
Source Code Management

Source Code Management

https://github.com/jordanbonaldi/WebViewsExtractor/tree/master

Download webviewsextractor

How to add to project

<!-- https://jarcasting.com/artifacts/net.neferett/webviewsextractor/ -->
<dependency>
    <groupId>net.neferett</groupId>
    <artifactId>webviewsextractor</artifactId>
    <version>2.1.7</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/net.neferett/webviewsextractor/
implementation 'net.neferett:webviewsextractor:2.1.7'
// https://jarcasting.com/artifacts/net.neferett/webviewsextractor/
implementation ("net.neferett:webviewsextractor:2.1.7")
'net.neferett:webviewsextractor:aar:2.1.7'
<dependency org="net.neferett" name="webviewsextractor" rev="2.1.7">
  <artifact name="webviewsextractor" type="aar" />
</dependency>
@Grapes(
@Grab(group='net.neferett', module='webviewsextractor', version='2.1.7')
)
libraryDependencies += "net.neferett" % "webviewsextractor" % "2.1.7"
[net.neferett/webviewsextractor "2.1.7"]

Dependencies

compile (3)

Group / Artifact Type Version
androidx.appcompat » appcompat jar 1.1.0
androidx.constraintlayout » constraintlayout jar 1.1.3
net.neferett : webviewsinjector jar 2.1.2

Project Modules

There are no modules declared in this project.

WebView Extractor using synchronous and asynchronous javascript file injection

License: MPL 2.0 Maven Central GitHub release Codacy Badge

Private Data Extraction using WebViewsInjection for autologin on the below services, and injection of javascript files containing asynchronous or synchronous extractions.

Current Services

Research Engine:

  • Google.com (Maps)

Travelling Websites:

  • Hotels.com
  • Booking.com
  • Expedia.com
  • Trainline
  • Agoda

Online Social Networks:

  • Twitter
  • Facebook
  • Instagram
  • Pinterest

You can also:

  • Using accordingly WebViewsInjector and your own new Services, create new injection scripts

Installation

Install the dependency with Gradle inside your Main Application

    dependencies {
        implementation 'net.neferett:webviewsextractor:2.1.7'
    }

Don't forget to add maven central in your repositories:

    buildscript {
      repositories {
          google()
          jcenter()
          mavenCentral()
      }
    }

Add INTERNET permission to your android application

    <uses-permission android:name="android.permission.INTERNET" />

How to use it

Here's what you need to implement, to have an automated LoginService

    // Context should be your Main Activity of your application
    LoginService loginService = new GoogleService(context);
    // Email and Password should be clear string
    loginService.autoLogin(<email>, <password>, new ResponseCallback() {
        @Override
        public void getResponse(ResponseEnum responseEnum, String data) {
            if (responseEnum == ResponseEnum.SUCCESS) {
                DataExtractor dataExtractor = new DataExtractor(loginService);  
  
		dataExtractor.injectAll(<context>, (jsonArray, status) -> {
		    //JSONArray is what you return from your/our scripts
		    //JSONArray will be null if not JSON format
		    //Status allows you to see the processing of all the injection files
		    
			//status.getFailedData();  
			//status.getSucceedData();  
			//status.getRemainingData();
		});
	     }
        }
    });

All DataExtractor Injection Methods

Default Method to Inject all scripts matching with the login

 injectAll(Context context, ExtractionCallback extractionCallback);

Using a list of scripts or name of scripts using string

 injectAllScripts(Context context, ExtractionCallback extractionCallback, List<Script> scripts);
 
 injectAllScriptsByListName(Context context, ExtractionCallback extractionCallback, List<String> scriptsNames);
 
 List<Script> getScripts(); // Getting the full scripts list
 List<String> getStringScripts(); //Getting the full scripts names 

You can directly put them using va args (infinite args)

  injectAllScripts(Context context, ExtractionCallback extractionCallback, Script ... scripts);
  
  injectAllScriptsByListName(Context context, ExtractionCallback extractionCallback, List<String> scriptsNames);

Lastly simple script name injection:

  injectScriptByName(String name, ExtractionCallback extractionCallback);

Create a synchronous injection file

First you must create a javascript file into res/raw folder of your application.

At the top of the file you need to include the url to inject the file in using the following format:

//url:https://twitter.com/settings/profile

You can add an optional parameter to create latency before injection (the latency is in seconds):

//latency:5

Lastly, you must return your values using the custom javascript function:

Injector.promiseReceive(...);

Example of a full injection file:

	//url:https://twitter.com/settings/profile  
	//latency:5  
	
	Injector.promiseReceive(JSON.stringify([  
	 {  
		 title: 'First Name',  
		 type: 'profile',  
		 value: document.getElementById('firstName').value,  
		 data: []  
	 }, {  
		 title: 'Last name',  
		 type: 'profile',  
		 value: document.getElementById('lastName').value,  
		 data: []  
	 }, {  
		 title: 'Email address',  
		 type: 'profile',  
		 value: document.getElementById('email').value,  
		 data: []  
	 }]
	));

Be careful to not use 'let' in your javascript file, it can create errors in some web browser versions.

Create an asynchronous injection file

The creation procedure is exactly the same, because we call our callback once

Injector.promiseReceive(...);

is called. Here's an example of an asynchronous injection file:

	//url:https://twitter.com/settings/profile  
	
	new Promise((res) => {  
	  setTimeout(res, 5000)  
	}).then(() => {  
	  Injector.promiseReceive(JSON.stringify([  
		 {  
			 title: 'First Name',  
			 type: 'profile',  
			 value: document.getElementById('firstName').value,  
			 data: []  
		 }, {  
			 title: 'Last name',  
			 type: 'profile',  
			 value: document.getElementById('lastName').value,  
			 data: []  
		 }, {  
			 title: 'Email address',  
			 type: 'profile',  
			 value: document.getElementById('email').value,  
			 data: []  
		 }]
	  ));
	});

PriVELT

Android application to centralise known data from different services. The project is funded by PriVELT (https://privelt.ac.uk/). The project is based on scraping and is only for researches purposes.

License

Mozilla Public License 2.0

Versions

Version
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.1
2.0.6
2.0.5
2.0.4
2.0.2
2.0.1
2.0.0