var load_finished_called = false;
var done_print = false;
+ var queue_print = -1;
+
+
+ var load_started = function(fr)
+ {
+ print("load started");
+ queue_print++;
+ }
+
+
var do_print = function(web_frame) {
-
- if (done_print) {
- print("do_print called -- while already doing this...");
- return;
- }
- done_print = true;
- print("do_print called");
-
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/remove_print_css.js")
- );
-
- var url_p = current_url.split('/');
- print(JSON.stringify(url_p));
-
- if (current_url.match(/\.coconuts\.co\//) ) {
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/coconuts.co.js")
- );
-
- }
- if (current_url.match(/\.itnewsafrica\.com\//) ) {
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/itnewsafrica.com.js")
- );
- }
- if (current_url.match(/\.indiatimes\.com\//) ) {
- print("running indiatimes code");
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/indiatimes.com.js")
- );
- }
-
- if (current_url.match(/\.inquirer\.net\//) ) {
- print("add inquirer.net code");
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/inquirer.net.js")
- );
-
- }
- if (current_url.match(/\.puntocellulare\.it\//) ) {
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/puntocellulare.it.js")
- );
-
- }
-
- // motorme - requires a scroll to make content appear..
- if (current_url.match(/\.motorme\.my\//) ) {
- TabbedBrowser.browser.current_tab().get_web_view().execute_script("window.scrollTo(0,500);");
-
- }
-
- if (current_url.match(/\.efytimes\.com\//) || current_url.match(/\/efytimes\.com\//) ) {
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- File.read( __script_path__ + "/domains/efytimes.com.js")
- );
- }
-
-
- print("Delay:" + BrowserSettings.delay);
-
- GLib.timeout_add(GLib.PRIORITY_DEFAULT, BrowserSettings.delay *1, function() {
+ var realprint = function() {
+ print("realprint called - queue is " + queue_print);
+ if (queue_print > 0) {
+ print("ignore print - queue is " + queue_print);
+ queue_print--;
+ return;
+ }
try {
print("error occured");
print(JSON.stringify(e));
}
- });
+ };
+
+
+
+ if (done_print) {
+
+ print("do_print called -- while already doing this... - restarting queue...");
+ GLib.timeout_add(GLib.PRIORITY_DEFAULT, BrowserSettings.delay *1, realprint);
+
+ return;
+ }
+ done_print = true;
+ print("do_print called");
+
+
+ TabbedBrowser.browser.current_tab().get_web_view().execute_script(
+ File.read( __script_path__ + "/domains/remove_print_css.js")
+ );
+
+ var url_p = current_url.split('/');
+ var dom = url_p[2];
+ var dom_p = url_p[2].split('.');
+ var chk = dom_p.pop();
+ chk = dom_p.pop() + '.' + chk;
+
+
+
+ print("CHECK: " + chk +"\n");
+ if (File.exists( __script_path__ + "/domains/" + chk + '.js')) {
+ print("INCLUDING: " + __script_path__ + "/domains/"+ chk + ".js\n");
+ TabbedBrowser.browser.current_tab().get_web_view().execute_script(
+ File.read( __script_path__ + "/domains/"+ chk + ".js")
+ );
+ }
+
+
+ // motorme - requires a scroll to make content appear..
+ if (current_url.match(/\.motorme\.my\//) ) {
+ TabbedBrowser.browser.current_tab().get_web_view().execute_script("window.scrollTo(0,500);");
+
+ }
+
+
+ print("Delay:" + BrowserSettings.delay);
+
+
+
+ GLib.timeout_add(GLib.PRIORITY_DEFAULT, BrowserSettings.delay *1, realprint);
}
load_finished_called = true;
-
-// if(document.location.host=='weibo.com') {
-// // clear login dialog from weibo.
-// //check and hidden the login dialog and overlay .....
-// var els = document.querySelectorAll('div[node-type]');
-// var bbc = [];
-// for (i = 0; i < els.length; i++) {
-// if (els[i].hasAttribute('node-type')) {
-// if(els[i].getAttribute('node-type') == 'outer'){
-// bbc.push(els[i]);
-// }
-// }
-// }
-// for (i = 0; i < bbc.length; i++) {// hide all the outer.....
-// bbc[i].style.display = 'none';
-// }
-//
-// //try to login
-// if(document.location.pathname == '/login.php'){
-//
-// // fills in the user name and password
-// var els = document.querySelectorAll('input[node-type]');
-//
-// for (i = 0; i < els.length; i++) {
-// if (els[i].hasAttribute('node-type')) {
-// if(els[i].getAttribute('node-type') == 'username'){
-// els[i].value = BrowserSettings.username;
-// }
-// if(els[i].getAttribute('node-type') == 'password'){
-// els[i].value = BrowserSettings.passwd;
-// }
-// }
-// }
-//
-//
-// // simulating click event to login ....
-// var elss = document.querySelectorAll('a[node-type]');
-//
-// for (i = 0; i < elss.length; i++) {
-// if (elss[i].hasAttribute('node-type')) {
-// if(elss[i].getAttribute('node-type') == 'submitBtn'){
-// elss[i].click();
-// }
-// }
-// }
-//
-//
-// }
-//
-// }
-
-
- // clear login dialog from weibo.
-// TabbedBrowser.browser.current_tab().get_web_view().execute_script(
-// " if (document.location.host=='weibo.com') { " +
-// " try { " +
-// " var a = document.getElementsByClassName('W_layer')[0]; " +
-// " a.parentNode.removeChild(a.previousSibling); " +
-// " a.parentNode.removeChild(a); " +
-// " } catch(e) { } } " );
-
-
- return;
- GLib.timeout_add(GLib.PRIORITY_LOW, BrowserSettings.delay, function() {
-
- var mf = _t.get_main_frame();
-
- var ar = Gtk.PaperSize.get_paper_sizes();
- var psetup = new Gtk.PageSetup();
- for(var i = 0; i < ar.length; i++) {
- if (ar[i].get_name() =='iso_a2') {
- psetup.set_paper_size(ar[i]);
- }
- }
-
- var p = new Gtk.PrintOperation({ export_filename : BrowserSettings.export_filename });
- p.set_default_page_setup(psetup);
- mf.print_full(p, Gtk.PrintOperationAction.EXPORT);
- print("made image - exiting");
-
- Seed.quit();
- return true;
- });
-
- return;
+
};
-
- var load_committed = function (web_view, web_frame)
- {
- print("load commited");
-
- update_url(web_view, web_frame);
-
- // call load finished after 20seconds??
- // so even if it never complets we try and print the thing.
- GLib.timeout_add(GLib.PRIORITY_LOW, 40000, function() {
- print("load commited - 3000 ms?");
- load_finished();
- });
-
- };
+
var clicked_link = function (web_view, web_frame, request,
action, decision, window)
//this.signal.title_changed.connect(update_title);
//this.signal.load_committed.connect(load_committed);
this.signal.load_finished.connect(load_finished);
+ this.signal.load_started.connect(load_started);
// For some reason, this segfaults seed in the instance init closure handler