-
Notifications
You must be signed in to change notification settings - Fork 32
/
declarative-content.go
65 lines (53 loc) · 1.73 KB
/
declarative-content.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package chrome
import (
"fmt"
"github.com/gopherjs/gopherjs/js"
)
type DeclarativeContent struct {
o *js.Object
OnPageChanged *OnPageChanged //Need to remove this and fix methods below...
}
type OnPageChanged struct {
o *js.Object
}
func NewDeclarativeContent(declarativeContentObj *js.Object) *DeclarativeContent {
d := new(DeclarativeContent)
d.o = declarativeContentObj
fmt.Println(d.o.String())
if d.o.String() != "undefined" {
d.OnPageChanged = &OnPageChanged{o: d.o.Get("onPageChanged")}
} else {
d.OnPageChanged = &OnPageChanged{o: nil}
}
return d
}
/*
* Types
*/
type PageStateMatcher struct {
js.Object
PageUrl Object `js:"pageUrl"`
Css []string `js:"css"`
}
type RequestContentScript struct {
js.Object
Css []string `js:"css"`
Js []string `js:"js"`
AllFrames bool `js:"allFrames"`
MatchAboutBlank bool `js:"matchAboutBlank"`
}
/*
* Events
*/
// AddRules takes an array of rule instances as its first parameter and a callback function that is called on completion
func (e *OnPageChanged) AddRules(rules []map[string]interface{}, callback func(details map[string]interface{})) {
e.o.Call("addRules", rules, callback)
}
// RemoveRules accepts an optional array of rule identifiers as its first parameter and a callback function as its second parameter.
func (e *OnPageChanged) RemoveRules(ruleIdentifiers []string, callback func()) {
e.o.Call("removeRules", ruleIdentifiers, callback)
}
// GetRules accepts an optional array of rule identifiers with the same semantics as removeRules and a callback function.
func (e *OnPageChanged) GetRules(ruleIdentifiers []string, callback func(details map[string]interface{})) {
e.o.Call("getRules", ruleIdentifiers, callback)
}