Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / ui / accessibility / extensions / colorenhancer / src / common.js
blobe9ed9086fa1eb35672f527b236abbcceed5fe10f
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // TODO(wnwen): Move most of these functions to their own page rather than
6 // common, which should be shared with content script.
8 /**
9 * TODO(wnwen): Remove this and use actual web API.
11 function $(id) {
12 return document.getElementById(id);
16 /**
17 * TODO(wnwen): Remove this, it's terrible.
19 function siteFromUrl(url) {
20 var a = document.createElement('a');
21 a.href = url;
22 return a.hostname;
26 /**
27 * The filter should not apply to these URLs.
29 * @param {string} url The URL to check.
31 function isDisallowedUrl(url) {
32 return url.indexOf('chrome') == 0 || url.indexOf('about') == 0;
36 /**
37 * Whether extension is loaded unpacked or from Chrome Webstore.
38 * @const {boolean}
40 var IS_DEV_MODE = !('update_url' in chrome.runtime.getManifest());
43 /**
44 * Easily turn on/off console logs.
46 * @param {*} message The message to potentially pass to {@code console.log}.
48 function debugPrint(str) {
49 if (IS_DEV_MODE)
50 console.log(str);