Project

General

Profile

« Previous | Next » 

Revision b7e2870f

Added by koszko about 2 years ago

show some settings of the current page in the popup

View differences:

common/misc.js
10 10
 * IMPORT sha256
11 11
 * IMPORT browser
12 12
 * IMPORT is_chrome
13
 * IMPORT TYPE_NAME
13 14
 * IMPORTS_END
14 15
 */
15 16

  
......
71 72
    return rule;
72 73
}
73 74

  
75
/*
76
 * Print item together with type, e.g.
77
 * nice_name("s", "hello") → "hello (script)"
78
 */
79
function nice_name(prefix, name)
80
{
81
    return `${name} (${TYPE_NAME[prefix]})`;
82
}
83

  
84
/* Open settings tab with given item's editing already on. */
85
function open_in_settings(prefix, name)
86
{
87
    name = encodeURIComponent(name);
88
    const url = browser.runtime.getURL("html/options.html#" + prefix + name);
89
    window.open(url, "_blank");
90
}
91

  
92
/* Check if url corresponds to a browser's special page */
93
function is_privileged_url(url)
94
{
95
    return !!/^(chrome(-extension)?|moz-extension):\/\/|^about:/i.exec(url);
96
}
97

  
74 98
/*
75 99
 * EXPORTS_START
76 100
 * EXPORT gen_unique
77 101
 * EXPORT url_item
78 102
 * EXPORT url_extract_target
79 103
 * EXPORT csp_rule
104
 * EXPORT nice_name
105
 * EXPORT open_in_settings
106
 * EXPORT is_privileged_url
80 107
 * EXPORTS_END
81 108
 */

Also available in: Unified diff