1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-18 18:48:45 +02:00

code review

This commit is contained in:
gorhill 2015-06-17 13:49:43 -04:00
parent 9406e40fdc
commit 34485a0465
7 changed files with 721 additions and 580 deletions

View File

@ -1,42 +1,44 @@
#uBlock-legacy-button { #uBlock0-legacy-button {
list-style-image: url('../img/browsericons/icon-large.svg'); list-style-image: url('../img/browsericons/icon-large.svg');
} }
#uBlock-legacy-button.off { #uBlock0-legacy-button.off {
list-style-image: url('../img/browsericons/icon-large-off.svg'); list-style-image: url('../img/browsericons/icon-large-off.svg');
} }
toolbar[iconsize="small"] #uBlock-legacy-button { toolbar[iconsize="small"] #uBlock0-legacy-button {
list-style-image: url('../img/browsericons/icon16.svg'); list-style-image: url('../img/browsericons/icon16.svg');
} }
toolbar[iconsize="small"] #uBlock-legacy-button.off { toolbar[iconsize="small"] #uBlock0-legacy-button.off {
list-style-image: url('../img/browsericons/icon16-off.svg'); list-style-image: url('../img/browsericons/icon16-off.svg');
} }
#uBlock-legacy-button[badge]::before { #uBlock0-legacy-button[badge]::before {
position: fixed; background: #555;
margin-top: -2px;
padding: 1px 2px;
font-size: 9px;
font-weight: bold;
color: #fff; color: #fff;
background: #666;
content: attr(badge); content: attr(badge);
font: bold 10px sans-serif;
margin-top: -2px;
padding: 0 2px;
position: fixed;
} }
/* This hack required because if the before content changes it de-pops the popup (without firing any events). So just hide it instead. Note, can't actually *hide* it, or the same thing happens. '*/ /* This hack required because if the before content changes it de-pops the
#uBlock-legacy-button[badge=""]::before { popup (without firing any events). So just hide it instead. Note, can't
padding: 0; actually *hide* it, or the same thing happens.
**/
#uBlock0-legacy-button[badge=""]::before {
padding: 0;
} }
/* Override off state when in palette */ /* Override off state when in palette */
toolbarpaletteitem #uBlock-legacy-button.off { toolbarpaletteitem #uBlock0-legacy-button.off {
list-style-image: url('../img/browsericons/icon-large.svg'); list-style-image: url('../img/browsericons/icon-large.svg');
} }
/* Override badge when in palette */ /* Override badge when in palette */
toolbarpaletteitem #uBlock-legacy-button[badge]::before { toolbarpaletteitem #uBlock0-legacy-button[badge]::before {
content: none; content: none;
} }
/* Prevent pale moon from showing the arrow underneath the button */ /* Prevent pale moon from showing the arrow underneath the button */
#uBlock-legacy-button .toolbarbutton-menu-dropmarker { #uBlock0-legacy-button .toolbarbutton-menu-dropmarker {
-moz-box-orient: horizontal; -moz-box-orient: horizontal;
} }

View File

@ -331,17 +331,6 @@ const contentObserver = {
let docReady = (e) => { let docReady = (e) => {
let doc = e.target; let doc = e.target;
doc.removeEventListener(e.type, docReady, true); doc.removeEventListener(e.type, docReady, true);
if (doc.docShell) {
// It is possible, in some cases (#1140) for document-element-inserted to occur *before* nsIWebProgressListener.onLocationChange, so ensure that the URL is correct before continuing
let messageManager = doc.docShell.getInterface(Ci.nsIContentFrameMessageManager);
messageManager.sendSyncMessage(locationChangedMessageName, {
url: loc.href,
noRefresh: true, // If the URL is the same, then don't refresh it so that if this occurs after onLocationChange, no the block count isn't reset
});
}
lss(this.contentBaseURI + 'contentscript-end.js', sandbox); lss(this.contentBaseURI + 'contentscript-end.js', sandbox);
if ( doc.querySelector('a[href^="abp:"]') ) { if ( doc.querySelector('a[href^="abp:"]') ) {

File diff suppressed because it is too large Load Diff

View File

@ -38,8 +38,8 @@ vAPI.sessionId = String.fromCharCode(Date.now() % 26 + 97) +
/******************************************************************************/ /******************************************************************************/
vAPI.setTimeout = vAPI.setTimeout || function(callback, delay, args) { vAPI.setTimeout = vAPI.setTimeout || function(callback, delay, extra) {
return setTimeout(function(args) { callback(args); }, delay, args); return setTimeout(function(a) { callback(a); }, delay, extra);
}; };
/******************************************************************************/ /******************************************************************************/

View File

@ -40,8 +40,8 @@ var vAPI = self.vAPI = self.vAPI || {};
/******************************************************************************/ /******************************************************************************/
vAPI.setTimeout = vAPI.setTimeout || function(callback, delay, args) { vAPI.setTimeout = vAPI.setTimeout || function(callback, delay, extra) {
return setTimeout(function(args) { callback(args); }, delay, args); return setTimeout(function(a) { callback(a); }, delay, extra);
}; };
/******************************************************************************/ /******************************************************************************/
@ -125,14 +125,19 @@ vAPI.closePopup = function() {
// background page or auxiliary pages. // background page or auxiliary pages.
// 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.
const branchName = 'extensions.' + location.host + '.';
vAPI.localStorage = { vAPI.localStorage = {
PB: Services.prefs.getBranch(branchName), pbName: '',
pb: null,
str: Components.classes['@mozilla.org/supports-string;1'] str: Components.classes['@mozilla.org/supports-string;1']
.createInstance(Components.interfaces.nsISupportsString), .createInstance(Components.interfaces.nsISupportsString),
init: function(pbName) {
this.pbName = pbName;
this.pb = Services.prefs.getBranch(pbName);
},
getItem: function(key) { getItem: function(key) {
try { try {
return this.PB.getComplexValue( return this.pb.getComplexValue(
key, key,
Components.interfaces.nsISupportsString Components.interfaces.nsISupportsString
).data; ).data;
@ -142,7 +147,7 @@ vAPI.localStorage = {
}, },
setItem: function(key, value) { setItem: function(key, value) {
this.str.data = value; this.str.data = value;
this.PB.setComplexValue( this.pb.setComplexValue(
key, key,
Components.interfaces.nsISupportsString, Components.interfaces.nsISupportsString,
this.str this.str
@ -150,25 +155,27 @@ vAPI.localStorage = {
}, },
getBool: function(key) { getBool: function(key) {
try { try {
return this.PB.getBoolPref(key); return this.pb.getBoolPref(key);
} catch (ex) { } catch (ex) {
return null; return null;
} }
}, },
setBool: function(key, value) { setBool: function(key, value) {
this.PB.setBoolPref(key, value); this.pb.setBoolPref(key, value);
}, },
setDefaultBool: function(key, defaultValue) { setDefaultBool: function(key, defaultValue) {
Services.prefs.getDefaultBranch(branchName).setBoolPref(key, defaultValue); Services.prefs.getDefaultBranch(this.pbName).setBoolPref(key, defaultValue);
}, },
removeItem: function(key) { removeItem: function(key) {
this.PB.clearUserPref(key); this.pb.clearUserPref(key);
}, },
clear: function() { clear: function() {
this.PB.deleteBranch(''); this.pb.deleteBranch('');
} }
}; };
vAPI.localStorage.init('extensions.' + location.host + '.');
/******************************************************************************/ /******************************************************************************/
})(); })();

View File

@ -952,6 +952,9 @@ var startPicker = function(details) {
showDialog({ modifier: true }); showDialog({ modifier: true });
return; return;
} }
// A target was specified, but it wasn't found: abort.
stopPicker();
}; };
/******************************************************************************/ /******************************************************************************/

View File

@ -17,6 +17,7 @@ cp -R src/lib $DES/
cp -R src/_locales $DES/ cp -R src/_locales $DES/
cp src/*.html $DES/ cp src/*.html $DES/
mv $DES/img/icon_128.png $DES/icon.png mv $DES/img/icon_128.png $DES/icon.png
cp platform/firefox/css/* $DES/css/
cp platform/firefox/vapi-*.js $DES/js/ cp platform/firefox/vapi-*.js $DES/js/
cp platform/firefox/bootstrap.js $DES/ cp platform/firefox/bootstrap.js $DES/
cp platform/firefox/frame*.js $DES/ cp platform/firefox/frame*.js $DES/