[APP][XPOSED][7.0+] WeiJu2 - Scriptable Xposed Module

Search This thread

zhipingne

Member
Mar 20, 2018
16
24
logo_white.png


The first scriptable xposed module, provides a new way to change the application behavior.

Powered by Lua and made with ♥

Features​

  • Lua scripting
  • Simple and intuitive hook API
  • Share your package with others by publish it at WeiJu2-Scripts

Q&A​

How to write a hook?​

Code:
local Toast = import("android.widget.Toast")
local Activity = import("android.app.Activity")
local Bundle = import("android.os.Bundle")
local StringBuilder = import("java.lang.StringBuilder")

hook {
  class = Activity,
  returns = void,
  method = "onCreate",
  params = {
    Bundle
  },
  after = function(this, params)
    -- This will call the `StringBuilder(CharSequence seq)` constructor
    -- to instantiate a StringBuilder object
    local sb = StringBuilder("Hello, ")
    sb:append("WeiJu2")
 
    Toast:makeText(this, sb:toString(), Toast.LENGTH_SHORT):show()
    --              ^
    -- Note: `this` is the Activity instance
  end,
}


How to modify class fields?​

Code:
-- With the `import` function you can bind any java class, and access all the fields and methods that defined
-- in that class. No more `XposedHelper.setStaticObjectField(Build.class, "DEVICE", "coral")` much cleaner!
local Build = import("android.os.Build")

Build.DEVICE = "coral"
Build.PRODUCT = "coral"
Build.MODEL = "Google Pixel 4XL"
Build.BRAND = "google"
Build.MANUFACTURER = "google"
Build.VERSION.RELEASE = "13"

How to import a package?​

Code:
require("ikws4.system_variable").setup {
  -- configs goes here
}


How to create a package?​


A basic package template:

Code:
--[[
@metadata
  return {
    name = "my_package",
    author = "you",
    version = "1.0.0",
    description = "Describle your package"
  }
@end
--]]

local config = {
}

local M = {}

M.setup = function(opts)
  config = table.extend(config, opts or {})
end

return M


Want to share your work with others? Create a PR at WeiJu2-Scripts

Screenshots​

183251553-9dce66f7-953c-45b9-b741-0ae8e0b567af.png



Video guide​


Download​

Github release: nightly build
 
Last edited:

Rom

Senior Member
Jul 1, 2013
2,559
1,058
Lyon
Hi @zhipingne

Since from what i understand, it is possible to inject Lua code via Xposed with your application, in your opinion would it be possible to act on all applications embedding web browsers to navigate on web pages adapted to mobiles?

Example: inject CSS rules globally on all user applications to affect some like Spotify, Discord, Teams and others?

If it's possible I'll have fun!
 

zhipingne

Member
Mar 20, 2018
16
24
Hi @zhipingne

Since from what i understand, it is possible to inject Lua code via Xposed with your application, in your opinion would it be possible to act on all applications embedding web browsers to navigate on web pages adapted to mobiles?

Example: inject CSS rules globally on all user applications to affect some like Spotify, Discord, Teams and others?

If it's possible I'll have fun!
Sorry for the late response, I was experiment a way to inject custom css into WebView in the last two days, And finally got a working demo. (It took so mush time because of the `object` function, in order to proxy a concrete class we need to generate dex file at runtime lol)

FYI, I followed this article: https://medium.com/@fanisveizis/usi...d-js-scripts-on-android-webviews-6da0502d6595

UPDATE
It stop working... The `dex` file that generate at runtime does not loaded back properly in the next launch time.
 

Attachments

  • Screenshot_20220828-101812.png
    Screenshot_20220828-101812.png
    129.7 KB · Views: 82
  • Screenshot_20220828-101914.png
    Screenshot_20220828-101914.png
    164.4 KB · Views: 84
Last edited:

Rom

Senior Member
Jul 1, 2013
2,559
1,058
Lyon
Sorry for the late response, I was experiment a way to inject custom css into WebView in the last two days, And finally got a working demo. (It took so mush time because of the `object` function, in order to proxy a concrete class we need to generate dex file at runtime lol)

FYI, I followed this article: https://medium.com/@fanisveizis/usi...d-js-scripts-on-android-webviews-6da0502d6595

UPDATE
It stop working... The `dex` file that generate at runtime does not loaded back properly in the next launch time.
Ok, do you think it is possible to achieve something functional in the end?
I would be very interested.
Thx
 

Rom

Senior Member
Jul 1, 2013
2,559
1,058
Lyon
When i think about it, in fact your module can become as powerful as substratum if we want?
 

maxafe

Member
Jul 19, 2016
23
8
Salzburg
Code:
{
      "builtin": false,
      "collection": "Privacy",
      "group": "Use.Tracking",
      "name": "DeviceIntegrityCheck\/checkIntegrity",
      "author": "B!",
      "version": 0,
      "description": "Skip asitplus device integrity check",
      "className": "at.asitplus.utils.deviceintegrity.DeviceIntegrityCheck",
      "methodName": "checkIntegrity",
      "parameterTypes": [],
      "returnType": "void",
      "minSdk": 1,
      "maxSdk": 999,
      "minApk": 0,
      "maxApk": 2147483647,
      "enabled": true,
      "optional": false,
      "usage": true,
      "notify": false,
      "luaScript": "function before(hook, param)\n  param:setResult(nil)\n  return true\nend\n"
    }

(Thanks to B!GBOY)

Is it possible to run such a XPrivacyLua script? If so, how formatted?
 
  • Like
Reactions: ajolly and McHoffi

zhipingne

Member
Mar 20, 2018
16
24
Code:
{
      "builtin": false,
      "collection": "Privacy",
      "group": "Use.Tracking",
      "name": "DeviceIntegrityCheck\/checkIntegrity",
      "author": "B!",
      "version": 0,
      "description": "Skip asitplus device integrity check",
      "className": "at.asitplus.utils.deviceintegrity.DeviceIntegrityCheck",
      "methodName": "checkIntegrity",
      "parameterTypes": [],
      "returnType": "void",
      "minSdk": 1,
      "maxSdk": 999,
      "minApk": 0,
      "maxApk": 2147483647,
      "enabled": true,
      "optional": false,
      "usage": true,
      "notify": false,
      "luaScript": "function before(hook, param)\n  param:setResult(nil)\n  return true\nend\n"
    }

(Thanks to B!GBOY)

Is it possible to run such a XPrivacyLua script? If so, how formatted?


Code:
local DeviceIntegrityCheck = import("at.asitplus.utils.deviceintegrity.DeviceIntegrityCheck")

hook {
  class = DeviceIntegrityCheck,
  returns = void,
  method = "checkIntegrity",
  before = function(this, params)
    return nil
  end
}

Maybe, I can write a convertor for this.
 

jal3223

Senior Member
Mar 14, 2009
1,512
398
Google Pixel XL
Samsung Galaxy S8+
I'm sorry for the late response.
What do you mean not available? Is it can not be downloaded?
If so, here is the google drive link https://drive.google.com/file/d/1upurJDTJ5nS3RodsqLTCJKFg9daN4EaH/view?usp=sharing
Thank you for this module, it looks awesome! Do you think it would be possible to use it to implement java code, such as a java script to disable the elastic overscroll in Android 12+? There is an example in java located here that I would like to test.
https://github.com/ionic-team/capacitor/issues/5384
 

zhipingne

Member
Mar 20, 2018
16
24
Thank you for this module, it looks awesome! Do you think it would be possible to use it to implement java code, such as a java script to disable the elastic overscroll in Android 12+? There is an example in java located here that I would like to test.
https://github.com/ionic-team/capacitor/issues/5384

Yes, you can translate java code in to WeiJu2 scripts, here is an example:
Code:
local BridgeActivity = import("com.getcapacitor.BridgeActivity")

hook {
  class = BridgeActivity,
  returns = void,
  method = "onStart",
  after = function(this, params)
    local webview = this:getBridge():getWebView();
    webview:setOverScrollMode(webview.OVER_SCROLL_NEVER);
  end
}
Note: I did't test the code, it just an example to show it's possible to implement java code using WeiJu2 hook.


UPDATE

I think this code will make all view non over scrollable.
Code:
local View = import("android.view.View")

hook {
  class = View,
  returns = void,
  method = "setOverScrollMode",
  before = function(this, params)
    local OVER_SCROLL_NEVER = 2
    params[1] = OVER_SCROLL_NEVER
  end
}
 
Last edited:
  • Like
Reactions: VD171 and jal3223

jal3223

Senior Member
Mar 14, 2009
1,512
398
Google Pixel XL
Samsung Galaxy S8+
Yes, you can translate java code in to WeiJu2 scripts, here is an example:
Code:
local BridgeActivity = import("com.getcapacitor.BridgeActivity")

hook {
  class = BridgeActivity,
  returns = void,
  method = "onStart",
  after = function(this, params)
    local webview = this:getBridge():getWebView();
    webview:setOverScrollMode(webview.OVER_SCROLL_NEVER);
  end
}
Note: I did't test the code, it just an example to show it's possible to implement java code using WeiJu2 hook.


UPDATE

I think this code will make all view non over scrollable.
Code:
local View = import("android.view.View")

hook {
  class = View,
  returns = void,
  method = "setOverScrollMode",
  before = function(this, params)
    local OVER_SCROLL_NEVER = 2
    params[1] = OVER_SCROLL_NEVER
  end
}
Thank you for the reply. That's awesome to hear. I'm going to keep messing around with it to see if I can disable the overscroll then. The code that you provided unfortunately doesn't work for all apps. It does work for some however. I believe there is another hook somewhere that must be disabled as well. If you have any ideas they would be greatly appreciated.

Thank you again for the app. It's amazing!
 

zhipingne

Member
Mar 20, 2018
16
24
Thank you for the reply. That's awesome to hear. I'm going to keep messing around with it to see if I can disable the overscroll then. The code that you provided unfortunately doesn't work for all apps. It does work for some however. I believe there is another hook somewhere that must be disabled as well. If you have any ideas they would be greatly appreciated.

Thank you again for the app. It's amazing!

Try this to see if it works
Code:
local View = import "android.view.View"

local OVER_SCROLL_NEVER = 2

hook {
  class = View,
  params = {
    Context,
    AttributeSet,
    int,
  },
  after = function(this, params)
    this.mOverScrollMode = OVER_SCROLL_NEVER
  end,
}

hook {
  class = View,
  returns = void,
  method = "setOverScrollMode",
  before = function(this, params)
    params[1] = OVER_SCROLL_NEVER
  end,
}
 

jal3223

Senior Member
Mar 14, 2009
1,512
398
Google Pixel XL
Samsung Galaxy S8+
Try this to see if it works
Code:
local View = import "android.view.View"

local OVER_SCROLL_NEVER = 2

hook {
  class = View,
  params = {
    Context,
    AttributeSet,
    int,
  },
  after = function(this, params)
    this.mOverScrollMode = OVER_SCROLL_NEVER
  end,
}

hook {
  class = View,
  returns = void,
  method = "setOverScrollMode",
  before = function(this, params)
    params[1] = OVER_SCROLL_NEVER
  end,
}
Thank you for the attempt, but unfortunately, that doesn't seem to fix it either. I've asked multiple developers to see if they could sort it and nobody has been able to so far. I don't know how Google implemented it so deep, but it seems very difficult to remove the "accordion" scroll. Thank you for trying though. If you have any ideas though, they would be greatly appreciated.
 

wanting2521

New member
Oct 1, 2022
4
0
It work perfectly! Thank you very much.

One more thing, Is there a way we can load script from local file instead of write directly on module interface, please?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 6
    logo_white.png


    The first scriptable xposed module, provides a new way to change the application behavior.

    Powered by Lua and made with ♥

    Features​

    • Lua scripting
    • Simple and intuitive hook API
    • Share your package with others by publish it at WeiJu2-Scripts

    Q&A​

    How to write a hook?​

    Code:
    local Toast = import("android.widget.Toast")
    local Activity = import("android.app.Activity")
    local Bundle = import("android.os.Bundle")
    local StringBuilder = import("java.lang.StringBuilder")
    
    hook {
      class = Activity,
      returns = void,
      method = "onCreate",
      params = {
        Bundle
      },
      after = function(this, params)
        -- This will call the `StringBuilder(CharSequence seq)` constructor
        -- to instantiate a StringBuilder object
        local sb = StringBuilder("Hello, ")
        sb:append("WeiJu2")
     
        Toast:makeText(this, sb:toString(), Toast.LENGTH_SHORT):show()
        --              ^
        -- Note: `this` is the Activity instance
      end,
    }


    How to modify class fields?​

    Code:
    -- With the `import` function you can bind any java class, and access all the fields and methods that defined
    -- in that class. No more `XposedHelper.setStaticObjectField(Build.class, "DEVICE", "coral")` much cleaner!
    local Build = import("android.os.Build")
    
    Build.DEVICE = "coral"
    Build.PRODUCT = "coral"
    Build.MODEL = "Google Pixel 4XL"
    Build.BRAND = "google"
    Build.MANUFACTURER = "google"
    Build.VERSION.RELEASE = "13"

    How to import a package?​

    Code:
    require("ikws4.system_variable").setup {
      -- configs goes here
    }


    How to create a package?​


    A basic package template:

    Code:
    --[[
    @metadata
      return {
        name = "my_package",
        author = "you",
        version = "1.0.0",
        description = "Describle your package"
      }
    @end
    --]]
    
    local config = {
    }
    
    local M = {}
    
    M.setup = function(opts)
      config = table.extend(config, opts or {})
    end
    
    return M


    Want to share your work with others? Create a PR at WeiJu2-Scripts

    Screenshots​

    183251553-9dce66f7-953c-45b9-b741-0ae8e0b567af.png



    Video guide​


    Download​

    Github release: nightly build
    4
    Code:
    {
          "builtin": false,
          "collection": "Privacy",
          "group": "Use.Tracking",
          "name": "DeviceIntegrityCheck\/checkIntegrity",
          "author": "B!",
          "version": 0,
          "description": "Skip asitplus device integrity check",
          "className": "at.asitplus.utils.deviceintegrity.DeviceIntegrityCheck",
          "methodName": "checkIntegrity",
          "parameterTypes": [],
          "returnType": "void",
          "minSdk": 1,
          "maxSdk": 999,
          "minApk": 0,
          "maxApk": 2147483647,
          "enabled": true,
          "optional": false,
          "usage": true,
          "notify": false,
          "luaScript": "function before(hook, param)\n  param:setResult(nil)\n  return true\nend\n"
        }

    (Thanks to B!GBOY)

    Is it possible to run such a XPrivacyLua script? If so, how formatted?


    Code:
    local DeviceIntegrityCheck = import("at.asitplus.utils.deviceintegrity.DeviceIntegrityCheck")
    
    hook {
      class = DeviceIntegrityCheck,
      returns = void,
      method = "checkIntegrity",
      before = function(this, params)
        return nil
      end
    }

    Maybe, I can write a convertor for this.
    2
    Strangely, I check both path:
    - data/data/io.ikws4.weiju
    - /data/user_de/0/io.ikws4.weiju
    But no shared_prefs folder there. where can it be, sir? :(

    try global search the file name. In my case, it was located at
    Code:
    /data/misc/b7076e05-6693-44af-990c-d5a46af38289/prefs/io.ikws4.weiju/script_store.xml
    2
    The version is not available...
    I'm sorry for the late response.
    What do you mean not available? Is it can not be downloaded?
    If so, here is the google drive link https://drive.google.com/file/d/1upurJDTJ5nS3RodsqLTCJKFg9daN4EaH/view?usp=sharing
    2
    Code:
    {
          "builtin": false,
          "collection": "Privacy",
          "group": "Use.Tracking",
          "name": "DeviceIntegrityCheck\/checkIntegrity",
          "author": "B!",
          "version": 0,
          "description": "Skip asitplus device integrity check",
          "className": "at.asitplus.utils.deviceintegrity.DeviceIntegrityCheck",
          "methodName": "checkIntegrity",
          "parameterTypes": [],
          "returnType": "void",
          "minSdk": 1,
          "maxSdk": 999,
          "minApk": 0,
          "maxApk": 2147483647,
          "enabled": true,
          "optional": false,
          "usage": true,
          "notify": false,
          "luaScript": "function before(hook, param)\n  param:setResult(nil)\n  return true\nend\n"
        }

    (Thanks to B!GBOY)

    Is it possible to run such a XPrivacyLua script? If so, how formatted?