domains/remove_print_css.js
[app.webkitpdf] / webkitpdf.vala
index 69a8048..e9ececc 100644 (file)
@@ -3,8 +3,8 @@
  sudo valac   --vapidir=. --thread  webkitpdf.vala  BrowserWindow.vala  --vapidir=./vapi \
     --pkg glib-2.0 --pkg webkit-1.0 --pkg gtk+-2.0 -o /usr/bin/webkitpdf --target-glib=2.32 
   
- sudo valac -DGTK3  --vapidir=. --thread  webkitpdf.vala  BrowserWindow.vala  --vapidir=./vapi \
-    --pkg glib-2.0 --pkg webkit2gtk-4.0 --pkg gtk+-3.0 -o /usr/bin/webkitpdf2 --target-glib=2.32 
+ sudo valac -D GTK3  --vapidir=. --thread  webkitpdf.vala  BrowserWindow.vala  --vapidir=./vapi \
+    --pkg glib-2.0 --pkg webkit2gtk-4.0 --pkg gtk+-3.0 --pkg gio-2.0 -o /usr/bin/webkitpdf2 --target-glib=2.32 
   
   
     
@@ -19,6 +19,8 @@ public class webkitpdf {
        public static string? opt_target_pdf = null;    
        [CCode (array_length = false, array_null_terminated = true)]
        public static string[] opt_inject_js;
+       public static string? opt_cookies = null;
+       
        const OptionEntry[] options = {
                
                        { "width", 0, 0, OptionArg.INT, ref opt_width, "Width (default 1200)", null },                  
@@ -28,6 +30,7 @@ public class webkitpdf {
                        { "png", 0, 0, OptionArg.STRING, ref opt_target_png, "File to write (PNG)", null },
                        { "inject", 0, 0, OptionArg.STRING_ARRAY, ref opt_inject_js, "Inject Javascript file(s)", null },
                        { "pdf", 0, 0, OptionArg.STRING, ref opt_target_pdf, "File to write (PDF)", null },
+                       { "cookies", 0, 0, OptionArg.STRING, ref opt_cookies, "Inject Cookie string", null },
                        { null }
        }; 
     public static int main(string[] args) 
@@ -36,16 +39,18 @@ public class webkitpdf {
                
                
 #if GTK3               
+       // this is a horrific hack from https://bugs.webkit.org/show_bug.cgi?id=128674
+               Environment.unset_variable("GNOME_DESKTOP_SESSION_ID");
+               Environment.unset_variable("DESKTOP_SESSION");          
+               // it should now fallb ack to http prox!?
+               
+               
+#else
                unowned string proxy = Environment.get_variable ("http_proxy");
                if (proxy != null && proxy.length > 0) {
                        var sess = WebKit.get_default_session();
                        sess.proxy_uri = new Soup.URI(proxy);
                }
-#else
-       // this is a horrific hack from https://bugs.webkit.org/show_bug.cgi?id=128674
-               Environment.unset_variable("GNOME_DESKTOP_SESSION_ID");
-               Environment.unset_variable("DESKTOP_SESSION");          
-               // it should now fallb ack to http prox!?
 #endif         
         var opt_context = new OptionContext ("webkitpdf");
        
@@ -70,6 +75,7 @@ public class webkitpdf {
             png: %s
             inject: %s
             PDF: %s
+            Cookie: %s
             """,
               opt_width,
               opt_height,
@@ -77,7 +83,9 @@ public class webkitpdf {
               (int) opt_delay,
               opt_target_png == null ? "--empty--" : opt_target_png,
               opt_inject_js.length < 1? "--empty--" : string.joinv(", ", opt_inject_js),
-              opt_target_pdf == null ? "--empty--" : opt_target_pdf
+              opt_target_pdf == null ? "--empty--" : opt_target_pdf,
+              opt_cookies == null ? "--empty--" : opt_cookies              
+              
             
             );