File: selectively-unstyle.js

package info (click to toggle)
conkeror 1.0.3%2Bgit170123-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,988 kB
  • sloc: ansic: 280; sh: 255; xml: 173; makefile: 69
file content (30 lines) | stat: -rw-r--r-- 965 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
 * (C) Copyright 2009 John J. Foerch
 *
 * Use, modification, and distribution are subject to the terms specified in the
 * COPYING file.
**/

define_variable('selectively_unstyle_alist', [],
    "Alist mapping url-matching regular expressions to predicates to "+
    "selectively disable stylesheets.  All predicates corresponding to "+
    "matching regexps will be used.  Predicates are functions of one "+
    "argument.  They receive a styleSheet object as their argument, and "+
    "if they return true, that stylesheet will be disabled.");


function selectively_unstyle (buffer) {
    var uri = buffer.current_uri.spec;
    for each (let entry in selectively_unstyle_alist) {
        if (entry[0](uri)) {
            let func = entry[1];
            for each (var sheet in buffer.document.styleSheets) {
                func(sheet);
            }
        }
    }
}

add_hook("buffer_loaded_hook", selectively_unstyle);

provide("selectively-unstyle");