OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 // TODO(wnwen): Move most of these functions to their own page rather than |
| 6 // common, which should be shared with content script. |
| 7 |
| 8 /** |
| 9 * TODO(wnwen): Remove this and use actual web API. |
| 10 */ |
| 11 function $(id) { |
| 12 return document.getElementById(id); |
| 13 } |
| 14 |
| 15 |
| 16 /** |
| 17 * TODO(wnwen): Remove this, it's terrible. |
| 18 */ |
| 19 function siteFromUrl(url) { |
| 20 var a = document.createElement('a'); |
| 21 a.href = url; |
| 22 return a.hostname; |
| 23 } |
| 24 |
| 25 |
| 26 /** |
| 27 * The filter should not apply to these URLs. |
| 28 * |
| 29 * @param {string} url The URL to check. |
| 30 */ |
| 31 function isDisallowedUrl(url) { |
| 32 return url.indexOf('chrome') == 0 || url.indexOf('about') == 0; |
| 33 } |
| 34 |
| 35 |
| 36 /** |
| 37 * Whether extension is loaded unpacked or from Chrome Webstore. |
| 38 */ |
| 39 function isDevMode = function() { |
| 40 return !('update_url' in chrome.runtime.getManifest()); |
| 41 } |
| 42 |
| 43 |
| 44 /** |
| 45 * Easily turn on/off console logs. |
| 46 * |
| 47 * @param {*} message The message to potentially pass to {@code console.log}. |
| 48 */ |
| 49 var debugPrint; |
| 50 if (isDevMode()) { |
| 51 debugPrint = console.log; |
| 52 } else { |
| 53 debugPrint = function() {}; |
| 54 } |
OLD | NEW |