new-tabs: fix bug in tab_bar_kill_buffer
[conkeror.git] / modules / selectively-unstyle.js
blob6ca95da8bdc50ff56be01992e1f7c23c31d0d6c2
1 /**
2  * (C) Copyright 2009 John J. Foerch
3  *
4  * Use, modification, and distribution are subject to the terms specified in the
5  * COPYING file.
6 **/
8 in_module(null);
10 define_variable('selectively_unstyle_alist', [],
11     "Alist mapping url-matching regular expressions to predicates to "+
12     "selectively disable stylesheets.  All predicates corresponding to "+
13     "matching regexps will be used.  Predicates are functions of one "+
14     "argument.  They receive a styleSheet object as their argument, and "+
15     "if they return true, that stylesheet will be disabled.");
18 function selectively_unstyle (buffer) {
19     var uri = buffer.current_uri.spec;
20     for each (let entry in selectively_unstyle_alist) {
21         if (entry[0](uri)) {
22             let func = entry[1];
23             for each (var sheet in buffer.document.styleSheets) {
24                 func(sheet);
25             }
26         }
27     }
30 add_hook("buffer_loaded_hook", selectively_unstyle);
32 provide("selectively-unstyle");