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"]'},
},
],
};
EOMAction 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.