简体   繁体   中英

How can I write a rule that selects on all pages?

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

select when pageview ".*"

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM