-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuserscripts.h
More file actions
80 lines (67 loc) · 2.04 KB
/
Copy pathuserscripts.h
File metadata and controls
80 lines (67 loc) · 2.04 KB
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
/* See LICENSE file for license and copyright information */
#ifndef USERSCRIPTS_H
#define USERSCRIPTS_H
#include <girara/types.h>
#include "jumanji.h"
#define USER_SCRIPTS_DIR "scripts"
typedef struct user_script_s
{
char* name; /**> Name of the user script */
char* description; /**> Description of the user script */
char* content; /**> User script code */
girara_list_t* include; /**> List of included url patterns */
girara_list_t* exclude; /**> List of excluded url patterns */
bool load_on_document_start; /**> Load on document start */
} user_script_t;
/**
* Loads all files from a directory as user scripts and returns a list
* of correctly parsed scripts
*
* @param path Path to the directory
* @return List of parsed scripts or NULL if an error occured
*/
girara_list_t* user_script_load_dir(const char* path);
/**
* Loads a single file as a userscript
*
* @param path Path to the file
* @return User script object or NULL if an error occured
*/
user_script_t* user_script_load_file(const char* path);
/**
* Frees an user script entry in the user script list
*
* @param data User script
*/
void user_script_free(void* data);
/**
* Load user script on webkit view
*
* @param web_view Webkit view
* @param user_script The user script
*/
void user_script_inject(WebKitWebView* web_view, user_script_t* user_script);
/**
* Load user script by content
*
* @param web_view Webkit view
* @param text The javascript code
*/
void user_script_inject_text(WebKitWebView* web_view, const char* text);
/**
* Sets up a webkit tab to use the user script implementation
*
* @param tab The jumanji tab
* @param user_scripts The list of user scripts
*/
void user_script_init_tab(jumanji_tab_t* tab, girara_list_t* user_scripts);
/**
* Callback that is used to load user scripts at the correct time
*
* @param web_view Webkit view
* @param pspec -
* @param user_scripts The list of user scripts
*/
void cb_user_script_tab_load_status(WebKitWebView* web_view, GParamSpec* pspec,
girara_list_t* user_scripts);
#endif // USERSCRIPTS_H