-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
plugin_example.js
185 lines (163 loc) · 6.2 KB
/
plugin_example.js
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// To connect the plugin, you need to add the path to the file "js/plugins.js" to the array "list: []"
window.nova_plugins.push({
id: 'time-jump', // unique identifier for the plugin. Used to store settings
title: 'Plugin Name', // optional. Plugin destination
// List of pages where the plugin can be launched
// eg:
// https://www.youtube.com/***/ <-- all pages
// https://www.youtube.com/channel/UC**** <-- channel
// https://www.youtube.com/watch?v=*** <-- watch
// minus in front denotes an exception
// exclude page from launch:
// https://www.youtube.com/embed/*** <-- -embed
run_on_pages: '*, home, results, feed, channel, playlist, watch, -embed, -live_chat',
// deactivate if use NOVA.HTMLElement.watch
restart_on_location_change: true, // optional. Restart plugin on every url change
/* optional GIU in options page: start */
section: 'player', // optional. Visual section in settings where the plugin belongs. Available list of values: header, player, details, comments, sidebar, other, channel
opt_api_key_warn: true, // optional. Graphical indicator in the settings depending on the api key
desc: 'Title description', // optional. Plugin description in settings. Don't use double quotes inside the text!
'plugins-conflict': 'plugin-id, plugin-id2, ...', // mark plugins with which the current plugin conflicts
// localization
// 'title:zh': '',
// 'title:ja': '',
// 'title:ko': '',
// 'title:vi': '',
// 'title:id': '',
// 'title:es': '',
// 'title:pt': '',
// 'title:fr': '',
// 'title:it': '',
// 'title:tr': '',
// 'title:de': '',
// 'title:pl': '',
// 'title:ua': '',
// 'desc:zh': '',
// 'desc:ja': '',
// 'desc:ko': '',
// 'desc:vi': '',
// 'desc:id': '',
// 'desc:es': '',
// 'desc:pt': '',
// 'desc:fr': '',
// 'desc:it': '',
// 'desc:tr': '',
// 'desc:de': '',
// 'desc:pl': '',
// 'desc:ua': '',
/* optional GIU in options page: end */
_runtime: user_settings => {
// user_settings - all extension settings. There is no division of settings into separate plugins
// YT API manual fuctions for player
// https://gist.github.com/Araxeus/fc574d0f31ba71d62215c0873a7b048e
// we wait for the effect on the page of the nuked object
// after finding at least one element, the search will be stopped
NOVA.waitSelector('#movie_player') // use css selector. Like document.body.querySelector
// wait, run the code
.then(node => { // returns the specified selector above
// do stuff
});
// If you want the search to not be stopped, use this construction
NOVA.watchElements({
selectors: 'a#thumbnail img[src]', // use css selector (array, srting). Like document.body.querySelectorAll('a#thumbnail img[src])
// The attribute with which the already found elements will be marked
attr_mark: 'nova-timestamps-updated', // delete if you want to constantly watch
callback: element => { // returns the specified selector above
// do stuff
},
});
// A complete list of available functions can be found in the file "/plugins/nova-api.js"
// And examples of their use in other plugins.
// I'm too lazy to describe them. Perhaps no one will even read what is written here.
// NOTE
// window.ytInitialData === document.body.querySelector('ytd-app')?.data?.response
// get YT experimental FLAGS
// let cfg = window.ytcfg.get("EXPERIMENT_FLAGS");
// cfg.kevlar_flexy_watch_new_dom = false;
// window.ytcfg.set("EXPERIMENT_FLAGS", cfg);
// movie_player.getVideoData()
// .video_id
// .isLive
// .title
// ...
// movie_player != document.body.querySelector('ytd-player')?.player_
// d(ocument.body.querySelector('ytd-player')?.player_
// .isFullscreen()
// ...
// movie_player
// .isFullscreen()
// mails are equal. Similar behavior
// window.addEventListener('transitionend' == 'yt-page-data-updated')
},
// Form element template for display in settings
options: {
// Attention! Object name must be unique and must not overlap with other plugins
'jump_step': { // Unique name for the storage.
_tagName: 'input', // item tag name
// Option Attribute List:
// attr: 'param',
label: 'Step',
// 'label:zh': '',
// 'label:ja': '',
// 'label:ko': '',
// 'label:vi': '',
// 'label:id': '',
// 'label:es': '',
// 'label:pt': '',
// 'label:fr': '',
// 'label:it': '',
// 'label:tr': '',
// 'label:de': '',
// 'label:pl': '',
// 'label:ua': '',
type: 'number',
title: 'sec',
// 'title:zh': '',
// 'title:ja': '',
// 'title:ko': '',
// 'title:vi': '',
// 'title:id': '',
// 'title:es': '',
// 'title:pt': '',
// 'title:fr': '',
// 'title:it': '',
// 'title:tr': '',
// 'title:de': '',
// 'title:pl': '',
// 'title:ua': '',
placeholder: 'sec',
step: 1,
min: 1,
max: 300,
value: 30,
},
// example of generating an option of the "select" type
'jump_hotkey': { // Unique name for the storage.
_tagName: 'select', // item tag name
// Option Attribute List:
label: 'select',
options: [
{ label: 'alt', value: 18 },
{ label: 'shift', value: 16 },
{ label: 'ctrl', value: 17, selected: true },
],
},
'jump_smooth': {
_tagName: 'input',
label: 'Smooth',
type: 'checkbox',
title: 'Help info',
'data-dependent': { 'jump_step': true },
},
url: {
_tagName: 'input',
label: 'URL',
type: 'url',
pattern: "https://.*",
// title: '',
placeholder: 'https://youtube.com/...',
value: 'https://sponsor.ajay.app',
required: true, // use from like input[type="text"], select[multiple="null"], select, textarea
},
}
});