Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void on_click(WebKit.DOM.EventTarget target, WebKit.DOM.Event event)
- {
- try
- {
- //var image = (WebKit.DOM.HTMLImageElement)target;
- //image.set_attribute("class", "clickable-img-hover");
- }
- catch(GLib.Error e)
- {
- }
- }
- public static void webkit_web_extension_initialize (WebKit.WebExtension web_extension)
- {
- string PROG = "[webkit2_webextension_minimal_so.so] ";
- print(PROG + "PLUGIN activated\n");
- web_extension.page_created.connect((extension, web_page)=> {
- print(PROG + "SIGNAL: page_created\n");
- try {
- var dom = web_page.get_dom_document();
- WebKit.DOM.Element img = dom.create_element("img");
- img.set_attribute("src", "file:///home/o/avatar.png");
- img.set_attribute("alt", "avatar-1.jpg");
- ((WebKit.DOM.EventTarget) img).add_event_listener_with_closure("click", on_click, false);
- dom.body.insert_before(img, null);
- } catch (FileError e) {
- stdout.printf ("Message: \"%s\"\n", e.message);
- stdout.printf ("Error code: FileError.EXIST = %d\n", e.code);
- stdout.printf ("FileErrors identification: %" + uint32.FORMAT + "\n", e.domain);
- }
- web_page.send_request.connect((request)=>
- {
- if(request.uri.has_prefix("http://www.google") || request.uri.has_prefix("data")){
- print(PROG + "SIGNAL: send request [REJECTED] " + request.uri + "\n");
- return true; // true => block query
- }
- print(PROG + "SIGNAL: send request " + request.uri + "\n");
- return false;
- });
- return;
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement