Code Monkey home page Code Monkey logo

Comments (10)

JingMatrix avatar JingMatrix commented on September 25, 2024 1

I just updated the JavaScript codes above to show you how to spoof UA using the ChromeXt API.
Note that it is impossible to spoof UA without using the ChromeXt API.

from chromext.

JingMatrix avatar JingMatrix commented on September 25, 2024

I don't it is possible or good to do this with Xposed hooks.
Instead, you may consider check UA within your JavaScript codes. Here is an example taking from my own script:

const ua =
  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114 Safari/537.36";

if (document.readyState == "loading") {
  window.addEventListener("DOMContentLoaded", switchToDesktop);
} else {
  switchToDesktop();
}

function switchToDesktop() {
  if (
    navigator.userAgent == ua &&
    document.documentElement.className != "mobile-web-player"
  ) {
    ...
  } else {
    ChromeXt.dispatch("syncData", {
      origin: window.location.origin,
      data: ua,
      name: "userAgent",
    });
    ChromeXt.dispatch("userAgentSpoof", window.location.href);
  }
}
// vim: set expandtab: set tabstop=2:

from chromext.

Me9ur1 avatar Me9ur1 commented on September 25, 2024

我看到了项目里对于loadurlparams的hook代码,我只是好奇为什么对于初次加载页面时,尽管我对这个类里的ua参数进行hook,但是并不生效,只有在刷新时或者通过chromext使用js时才会生效

from chromext.

JingMatrix avatar JingMatrix commented on September 25, 2024

The Chromium uses some lazy or cached logic to avoid parsing or analyzing LoadUrlParams multiple times.
Therefore, we can only hook UA when Chromium is not using cached parameters.

from chromext.

Me9ur1 avatar Me9ur1 commented on September 25, 2024

我大概了解了,感谢!

from chromext.

Me9ur1 avatar Me9ur1 commented on September 25, 2024

Hey bro,there is something wrong with my js code. Here is my code : https://greasyfork.org/zh-CN/scripts/482653-hidefingerprintforchromext/code

from chromext.

JingMatrix avatar JingMatrix commented on September 25, 2024

Please refer to the docs in README: https://github.com/JingMatrix/ChromeXt?tab=readme-ov-file#supported-api

You need to add @grant GM.ChromeXt.

from chromext.

Me9ur1 avatar Me9ur1 commented on September 25, 2024

现在加上了,但是在chrome的sp文件夹下没有发现useragent.xml被创建(但是我可以通过在kotlin层创建自定义的useragent.xml来实现ua伪装,只不过此时创建貌似时机不太对),我对js不太熟悉,抱歉:(

from chromext.

JingMatrix avatar JingMatrix commented on September 25, 2024

I cannot understand the description of your situation.
Moreover, you should clarify the folder or file locations you are referring to.

If the GM.ChromeXt API is not working as expected, please open an new issue and present how to reproduce it.
I am using ChromeXt API everyday and always using UserAgent Spoof endpoint, it is not likely to be a bug of the project. Better double check your JavaScript codes.

from chromext.

Me9ur1 avatar Me9ur1 commented on September 25, 2024

好的,我再检查一下吧

from chromext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.