如何编写在所有页面上进行选择的规则?

发布于 2024-10-03 14:44:17 字数 49 浏览 5 评论 0原文

在KRL(Kynetx规则语言)中,如何编写在所有页面上进行选择的select语句?

In KRL (Kynetx Rule Language), how can I write a select statement that selects on all pages?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

计㈡愣 2024-10-10 14:44:17

由于 KRL 中 Web 事件的 select 语句是正则表达式,因此您可以使用以下 select 语句在查看的所有页面上触发:

select when web pageview ".*"

完整规则集上下文中的示例:

ruleset a60x425 {
  meta {
    name "test select on all pages"
    description <<
      this will select on all pageviews
    >>
    author "Mike Grace"
    logging on
  }

  dispatch { }

  rule selection_test_on_all_pages {
    select when web pageview ".*"
    {
      notify("I selected on this page!","woot!") with sticky = true;
    }
  }
}

注 1:这并不能解决调度域和浏览器扩展的问题。当从书签执行时,这将按预期工作。除非当前查看的域与调度块中设置的域匹配,否则浏览器扩展不会进入选择表达式。此示例调度域是空白的,因为我假设应用程序将从书签运行。

注 2:选择表达式被编译为正则表达式,因此请务必记住,您不需要像在使用正则表达式的语言中的其他任何地方那样对表达式使用“re//”格式。

Because the select statements for web events in KRL are regular expressions you can use the following select statement to fire on all pages viewed:

select when web pageview ".*"

Example in context of full ruleset:

ruleset a60x425 {
  meta {
    name "test select on all pages"
    description <<
      this will select on all pageviews
    >>
    author "Mike Grace"
    logging on
  }

  dispatch { }

  rule selection_test_on_all_pages {
    select when web pageview ".*"
    {
      notify("I selected on this page!","woot!") with sticky = true;
    }
  }
}

Note 1: This doesn't address the issue of dispatch domains and browser extensions. This will work as expected when executed from a bookmarklet. Browser extensions won't make it to the selection expression unless the currently viewed domain matches a domain set in the dispatch block. This examples dispatch domain is blank because I am making the assumption that the app will be run from a bookmarklet.

Note 2: Selection expressions get compiled into a regular expression so it's important to remember that you don't need to use the 're//' format for the expression like you do everywhere else in language you use a regular expression.

燃情 2024-10-10 14:44:17
select when pageview ".*"
select when pageview ".*"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文