scenarioActor

Description
browser act scenario semi-automatic.
Latest version
0.0.7
Author
hogelog
License

for 2.2
http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/branches/2.2/scenario-actor.js
for 2.1
http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/branches/2.1/scenario-actor.js
for 2.0
http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/branches/2.0/scenario-actor.js
for 1.2
not supported
for Nightly
http://coderepos.org/share/browser/lang/javascript/vimperator-plugins/trunk/scenario-actor.js

Usage

browser act scenario semi-automatic.

Needs Library

SETTING

Scenario list is loaded by script under RUNTIME_PATH/plugin/scenario,
and liberator.globalVariables.userScenario.
liberator.globalVariables.userScenario can be set
by .vimperatorrc (or _vimperatorrc) using inline JavaScript.
// hatena sample
javascript <<EOM
liberator.globalVariables.userScenario = {
    DOMContentLoaded: [
    { // good by hatena keyword
        pattern: 'http://d.hatena.ne.jp/keyword/',
        action: [
            {sleep: 1000},
            {follow: '//a[contains(@href,"http://ja.wikipedia.org/wiki")]'},
        ],
    },
    { // auto paging hatena in 5 seconds
        pattern: 'hatena.ne.jp',
        action: {and: [
            {sleep: 5000},
            {follow: '//a[@rel="prev"]'},
        ]}
    },
    { // recent vector site is confusing
        pattern: 'http://www.vector.co.jp/soft/',
        action: {or: [
            {follow: ['//a[not(starts-with(@href,"http")) and contains(@href,"/soft/dl/")]', liberator.NEW_TAB]},
            {follow: '//a[not(starts-with(@href,"http")) and contains(@href,"/download/file/")]'},
        ]}
    },
    ],
    load: [
    { // auto hatena star
        pattern: 'hatena.ne.jp/',
        action:
            {follow: '//img[@class="hatena-star-add-button"]'},
    },
    ],
};
EOM
Action expressions like
action: {and: [
    {sleep: 5000},
    {follow: '//a[@rel="prev"]'},
]}
is syntax-sugar of
action: [{and: [
    {sleep: [5000]},
    {follow: ['//a[@rel="prev"]']},
]}]
and action expressions are quoted by {begin: ...}.

TODO

  • write more examples.
  • add more functions.
  • fix bugs.
  • a lot.
back to index