code review: jshint'ed

This commit is contained in:
gorhill 2015-01-21 08:59:23 -05:00
parent a64bca0fa6
commit 4edfae4b94
7 changed files with 17 additions and 18 deletions

View File

@ -95,7 +95,7 @@ vAPI.tabs.get = function(tabId, callback) {
var onTabReady = function(tab) {
// https://code.google.com/p/chromium/issues/detail?id=410868#c8
if ( chrome.runtime.lastError ) {
;
/* noop */
}
// Caller must be prepared to deal with nil tab value
callback(tab);
@ -110,7 +110,7 @@ vAPI.tabs.get = function(tabId, callback) {
var onTabReceived = function(tabs) {
// https://code.google.com/p/chromium/issues/detail?id=410868#c8
if ( chrome.runtime.lastError ) {
;
/* noop */
}
callback(tabs[0]);
};
@ -149,10 +149,8 @@ vAPI.tabs.open = function(details) {
};
if ( details.tabId ) {
details.tabId = parseInt(tabId, 10);
// update doesn't accept index, must use move
chrome.tabs.update(details.tabId, _details, function(tab) {
chrome.tabs.update(parseInt(details.tabId, 10), _details, function(tab) {
// if the tab doesn't exist
if ( vAPI.lastError() ) {
chrome.tabs.create(_details);
@ -219,7 +217,7 @@ vAPI.tabs.remove = function(tabId) {
/******************************************************************************/
vAPI.tabs.reload = function(tabId, flags) {
vAPI.tabs.reload = function(tabId /*, flags*/) {
if ( typeof tabId === 'string' ) {
tabId = parseInt(tabId, 10);
}

View File

@ -19,7 +19,8 @@
Home: https://github.com/gorhill/uBlock
*/
/* global punycode */
/* jshint esnext: true, bitwise: false */
/* global self, Components, punycode */
// For background page
@ -143,7 +144,7 @@ vAPI.storage = {
sqlWhere: function(col, params) {
if ( params > 0 ) {
params = Array(params + 1).join('?, ').slice(0, -2);
params = new Array(params + 1).join('?, ').slice(0, -2);
return ' WHERE ' + col + ' IN (' + params + ')';
}
@ -1000,7 +1001,7 @@ var httpObserver = {
// Probably isn't the best method to identify the source tab
if ( tabURI.spec !== lastRequest.openerURL ) {
continue
continue;
}
sourceTabId = vAPI.tabs.getTabId(tab);

View File

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock
*/
/* global µBlock, SafariBrowserTab */
/* global self, safari, SafariBrowserTab, µBlock */
// For background page
@ -360,7 +360,7 @@ vAPI.tabs.injectScript = function(tabId, details, callback) {
}
if ( details.file ) {
var xhr = new XMLHttpRequest;
var xhr = new XMLHttpRequest();
xhr.overrideMimeType('application/x-javascript;charset=utf-8');
xhr.open('GET', details.file, false);
xhr.send();

View File

@ -19,6 +19,7 @@
Home: https://github.com/gorhill/uBlock
*/
/* global vAPI */
/* exported µBlock */
/******************************************************************************/

View File

@ -261,7 +261,6 @@ NetFilteringResultCacheEntry.factory = function(result, type) {
/******************************************************************************/
// To mitigate memory churning
var uidGenerator = 1;
var netFilteringCacheJunkyard = [];
var netFilteringCacheJunkyardMax = 10;

View File

@ -68,7 +68,7 @@ var typeNameToTypeValue = {
'inline-script': 14 << 4,
'popup': 15 << 4
};
var typeOtherToTypeValue = typeNameToTypeValue['other'];
var typeOtherToTypeValue = typeNameToTypeValue.other;
const BlockAnyTypeAnyParty = BlockAction | AnyType | AnyParty;
const BlockAnyType = BlockAction | AnyType;
@ -1756,9 +1756,10 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r
pageHostname = context.pageHostname || '';
// Be prepared to support unknown types
var type = typeNameToTypeValue[requestType] || typeOtherToTypeValue;
var categories = this.categories;
var bf = false;
var bucket;
var categories = this.categories;
var type = typeNameToTypeValue[requestType] || typeOtherToTypeValue;
// Tokenize only once
this.tokenize(url);
@ -1779,7 +1780,6 @@ FilterContainer.prototype.matchStringExactType = function(context, requestURL, r
}
// Test against block filters
bf = false;
if ( bucket = categories[this.makeCategoryKey(BlockAnyParty | type)] ) {
bf = this.matchTokens(bucket, url);
}
@ -1855,12 +1855,13 @@ FilterContainer.prototype.matchString = function(context) {
// This will be used by hostname-based filters
pageHostname = context.pageHostname || '';
var bf, bucket;
var categories = this.categories;
var bucket;
// Tokenize only once
this.tokenize(url);
// https://github.com/gorhill/uBlock/issues/139
// Test against important block filters.
// The purpose of the `important` option is to reverse the order of

View File

@ -299,7 +299,6 @@ var headerValue = function(headers, name) {
/******************************************************************************/
var headerStartsWith = function(headers, prefix) {
var prefixLen = prefix.length;
var i = headers.length;
while ( i-- ) {
if ( headers[i].name.toLowerCase().lastIndexOf(prefix, 0) === 0 ) {