diff options
Diffstat (limited to 'conkeror/.conkerorrc/content-delay.js')
-rw-r--r-- | conkeror/.conkerorrc/content-delay.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/conkeror/.conkerorrc/content-delay.js b/conkeror/.conkerorrc/content-delay.js new file mode 100644 index 0000000..7999090 --- /dev/null +++ b/conkeror/.conkerorrc/content-delay.js @@ -0,0 +1,49 @@ +/* + +This script is a hack that provides delayed loading for content buffers. +The initial url of a buffer will not be loaded until that buffer is +switched to. Precaution is taken that the buffer's display_uri_string +returns the delayed url, not about:blank, so things like tabs and sessions +will still work properly. + +*/ + +function content_delay (spec) { + this.delayed_load = spec; +} + +function content_delay_init (b) { + if (b != b.window.buffers.current && + b instanceof content_buffer && + b.opener instanceof session_token) + { + b.load = content_delay; + b.__defineGetter__("display_uri_string", + function () { + if (this.delayed_load) { + if (this.delayed_load instanceof load_spec) + return load_spec_uri_string(this.delayed_load); + return this.delayed_load; + } + if (this._display_uri) + return this._display_uri; + if (this.current_uri) + return this.current_uri.spec; + return ""; + }); + } +} + +function content_delay_do_initial_load (b) { + if (b.hasOwnProperty("load")) { + delete b.load; + if (b.hasOwnProperty("delayed_load")) { + b.load(b.delayed_load); + delete b.delayed_load; + } + } +} + +add_hook("create_buffer_early_hook", content_delay_init); + +add_hook("select_buffer_hook", content_delay_do_initial_load); |