Coder Social home page Coder Social logo

Comments (6)

lisonge avatar lisonge commented on September 17, 2024 2

还有一个问题是,matches 如果是数组的话,多个选择器是且的关系吗?

matches 是数组的情况是,目标节点和关键信息信息节点在树结构上相隔太远了,规则写起来又臭又长

因此你可以理解为只要屏幕上有某些关键节点存在那么就点击最后一个节点

matches 是数组的情况下一般用得不多

from subscription.

lisonge avatar lisonge commented on September 17, 2024 1

我正在编写 订阅贡献指南 ,到时候你们提 pr 看看效果

from subscription.

lisonge avatar lisonge commented on September 17, 2024

https://github.com/gkd-kit/subscription/blob/main/CONTRIBUTING.md

写得可能不是很详细,有疑问可以提出

from subscription.

Sec-ant avatar Sec-ant commented on September 17, 2024

@lisonge 基本流程了解了,但我有个问题。拿下厨房为例,测试出来它目前有三种开屏广告需要不同的选择器,那么我最后写配置文件的时候,是要把这三种选择器放到 rules 里面的一个对象里,还是说分成三个对象?按照指南里的介绍,rules 中放多个对象似乎是为了实现分步骤点击动作?是说每一条 rule 判断且执行完毕之后才会转到下一条 rule 吗?

我目前写出来的配置是这个样子的:

export default defineAppConfig({
  id: 'com.xiachufang',
  name: '下厨房',
  groups: [
    {
      key: 1,
      name: '开屏广告',
      activityIds: ['com.xiachufang.startpage.ui.StartPageActivity'],
      rules: [
        {
          matches: '[id$="/tt_splash_skip_btn"]',
          snapshotUrls: ['https://gkd-kit.songe.li/import/12505985'],
        },
        {
          matches: '[id$="/start_page_count_down_tv"]',
          snapshotUrls: ['https://gkd-kit.songe.li/import/12506014'],
        },
        {
          matches: '[text$="跳过"]',
          snapshotUrls: [
            'https://gkd-kit.songe.li/import/12506014',
            'https://gkd-kit.songe.li/import/12506041',
          ],
        },
      ],
    },
  ],
});

但我不知道是不是应该改成这样?

defineAppConfig({
  id: 'com.xiachufang',
  name: '下厨房',
  groups: [
    {
      key: 1,
      name: '开屏广告',
      activityIds: ['com.xiachufang.startpage.ui.StartPageActivity'],
      rules: [
        {
          matches:
            '[id$="/tt_splash_skip_btn"||id$="/start_page_count_down_tv"||text$="跳过"]',
          snapshotUrls: [
            'https://gkd-kit.songe.li/import/12505985',
            'https://gkd-kit.songe.li/import/12506014',
            'https://gkd-kit.songe.li/import/12506041',
          ],
        },
      ],
    },
  ],
});

还有一个问题是,matches 如果是数组的话,多个选择器是且的关系吗?

from subscription.

lisonge avatar lisonge commented on September 17, 2024

group 是功能单位,比如开屏广告和应用内部广告应该两个 group

rule 是功能单位的细分,比如一个APP的开屏广告有数字倒计时/圆形倒计时广告,如果你能用一个选择器同时选中这两个节点,那就一个 rule,有时候这两个广告的节点结构完全不同,没有id/text/desc属性, 这种一个选择器坑定搞不定,因此用两条 rule

还有一种情况需要多个 rule,点击广告关闭-选择广告关闭原因-确认关闭,知乎的广告就是这种,这种也需要3个rule

是要把这三种选择器放到 rules 里面的一个对象里,还是说分成三个对象?

你这个完全可以合并成一个 rule,没必要遍历屏幕3次

是说每一条 rule 判断且执行完毕之后才会转到下一条 rule 吗?

是的,rule 的执行顺序先匹配第一个然后匹配第二个

就拿 点击广告关闭-选择广告关闭原因-确认关闭 来说,rule 的书写顺序最好应该是 rule_确认关闭 -> rule_选择广告关闭原因 -> rule_点击广告关闭

还有一个问题是,matches 如果是数组的话,多个选择器是且的关系吗?

subscription/src/types.ts

Lines 95 to 102 in c7c6c91

/**
* 一个或者多个合法的 GKD 选择器, 如果每个选择器都能匹配上节点, 那么点击最后一个选择器的目标节点
*/
matches?: IArray<string>;
/**
* 一个或者多个合法的 GKD 选择器, 如果存在一个选择器匹配上节点, 则停止匹配此规则
*/
excludeMatches?: IArray<string>;

from subscription.

lisonge avatar lisonge commented on September 17, 2024

另外比如百度贴吧的开屏广告

export default defineAppConfig({
id: 'com.baidu.tieba',
name: `百度贴吧`,
groups: [
{
key: 0,
name: '开屏广告',
desc: '数字倒计时广告,圆形倒计时广告',
activityIds: [
'com.baidu.tieba.tblauncher.MainTabActivity',
'com.baidu.tieba.pb.pb.main.PbActivity',
],
rules: [
'TextView[text*=`广告`] - TextView[text^=`跳过`]',
'[id=`com.kwad.dy.sdk:id/ksad_splash_circle_skip_view`] TextView[text=`跳过`]',
'[id=`com.byted.pangle:id/tt_splash_skip_btn`]',
],
},

这种明显无法合并成一个 rule,因此只能用 3 个 rule

from subscription.

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.