1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-18 17:02:27 +02:00

Merge branch 'master' of github.com:gorhill/uBlock

This commit is contained in:
gorhill 2015-03-14 14:59:49 -04:00
commit b0803dac9d
2 changed files with 32 additions and 22 deletions

View File

@ -29,6 +29,13 @@
'use strict'; 'use strict';
/******************************************************************************/
const {Services} = Components.utils.import(
'resource://gre/modules/Services.jsm',
null
);
self.vAPI = self.vAPI || {}; self.vAPI = self.vAPI || {};
/******************************************************************************/ /******************************************************************************/
@ -58,9 +65,8 @@ vAPI.download = function(details) {
/******************************************************************************/ /******************************************************************************/
vAPI.insertHTML = (function() { vAPI.insertHTML = (function() {
const {classes: Cc, interfaces: Ci} = Components; const parser = Components.classes['@mozilla.org/parserutils;1']
const parser = Cc['@mozilla.org/parserutils;1'].getService(Ci.nsIParserUtils); .getService(Components.interfaces.nsIParserUtils);
const io = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
return function(node, html) { return function(node, html) {
while ( node.firstChild ) { while ( node.firstChild ) {
@ -71,7 +77,7 @@ vAPI.insertHTML = (function() {
html, html,
parser.SanitizerAllowStyle, parser.SanitizerAllowStyle,
false, false,
io.newURI(document.baseURI, null, null), Services.io.newURI(document.baseURI, null, null),
document.documentElement document.documentElement
)); ));
}; };
@ -86,9 +92,9 @@ vAPI.getURL = function(path) {
/******************************************************************************/ /******************************************************************************/
vAPI.i18n = (function() { vAPI.i18n = (function() {
var stringBundle = Components.classes['@mozilla.org/intl/stringbundle;1'] var stringBundle = Services.strings.createBundle(
.getService(Components.interfaces.nsIStringBundleService) 'chrome://' + location.host + '/locale/messages.properties'
.createBundle('chrome://' + location.host + '/locale/messages.properties'); );
return function(s) { return function(s) {
try { try {
@ -114,12 +120,21 @@ vAPI.closePopup = function() {
// This storage is optional, but it is nice to have, for a more polished user // This storage is optional, but it is nice to have, for a more polished user
// experience. // experience.
vAPI.localStorage = { Object.defineProperty(vAPI, 'localStorage', {
key: function(){}, get: function() {
getItem: function(){}, if ( this._localStorage ) {
setItem: function(){}, return this._localStorage;
removeItem: function(){} }
};
this._localStorage = Services.domStorageManager.getLocalStorageForPrincipal(
Services.scriptSecurityManager.getCodebasePrincipal(
Services.io.newURI('http://ublock.raymondhill.net/', null, null)
),
''
);
return this._localStorage;
}
});
/******************************************************************************/ /******************************************************************************/

View File

@ -91,10 +91,10 @@ vAPI.getURL = function(path) {
// First language is the default // First language is the default
vAPI.i18nData = [ vAPI.i18nData = [
'en', 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el','es', 'et', 'fa', 'fi', 'en', 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'es', 'et', 'fa', 'fi',
'fil', 'fr', 'he', 'hi', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lt', 'lv', 'fil', 'fr', 'he', 'hi', 'hr', 'hu', 'id', 'it', 'ja', 'ko', 'lt', 'lv',
'mr', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sl', 'sq', 'sr', 'mr', 'nb', 'nl', 'pl', 'pt-BR', 'pt-PT', 'ro', 'ru', 'sl', 'sq', 'sr',
'sv', 'te', 'tr', 'uk', 'vi', 'zh-CN', 'zh-TW' 'sv', 'te', 'tr', 'uk', 'vi', 'zh-CN', 'zh-TW'
]; ];
vAPI.i18n = navigator.language; vAPI.i18n = navigator.language;
@ -135,11 +135,6 @@ vAPI.closePopup = function() {
// This storage is optional, but it is nice to have, for a more polished user // This storage is optional, but it is nice to have, for a more polished user
// experience. // experience.
vAPI.localStorage = { vAPI.localStorage = window.localStorage;
key: function(){},
getItem: function(){},
setItem: function(){},
removeItem: function(){}
};
})(); })();