PK
j2 content/PK
2 content/adsense/PK
2E content/adsense/about.xul
PK
2VnF# # " content/adsense/adsenseOptions.xul
PK
oy2'U U ' content/adsense/adsenseOptionsError.xul
PK
I2tHL HL ! content/adsense/adsenseOverlay.jsfunction AdsenseNotifier() {
this.init();
}
AdsenseNotifier.prototype.init = function() {
this._kWindowMediator = Components.classes[ "@mozilla.org/appshell/window-mediator;1" ].getService( Components.interfaces.nsIWindowMediator );
this._kPSWDMANAGER_CONTRACTID = "@mozilla.org/passwordmanager;1";
this._passwordManagerInternal = Components.classes[ this._kPSWDMANAGER_CONTRACTID ].createInstance( Components.interfaces.nsIPasswordManagerInternal );
this._passwordManager = Components.classes[ this._kPSWDMANAGER_CONTRACTID ].createInstance( Components.interfaces.nsIPasswordManager );
this._prefs = Components.classes[ "@mozilla.org/preferences-service;1" ].getService( Components.interfaces.nsIPrefService ).getBranch( "extensions.adsense." );
this.load_prefs();
}
AdsenseNotifier.prototype.load_prefs = function() {
this.login_attempts = 0;
try {
this.username = this._prefs.getCharPref( "username" );
this.pwupdate = this._prefs.getBoolPref( "pwupdate" );
this.password = this.get_password();
this.updateinterval = this._prefs.getIntPref( "updateinterval" );
this.openin = this._prefs.getIntPref( "openin" );
this.show_impressions = this._prefs.getBoolPref( "show_impressions" );
this.show_clicks = this._prefs.getBoolPref( "show_clicks" );
this.show_ctr = this._prefs.getBoolPref( "show_ctr" );
this.show_cpm = this._prefs.getBoolPref( "show_cpm" );
this.show_earnings = this._prefs.getBoolPref( "show_earnings" );
this.sort_by = this._prefs.getIntPref( "sort_by" );
this.group_by = this._prefs.getIntPref( "group_by" );
this.product = this._prefs.getIntPref( "product" );
} catch( err ) {}
var timeout = ( this.updateinterval >= 10 ) ? this.updateinterval : 10;
clearInterval( this.interval );
this.interval = setInterval( "oAdsenseNotifier.query_adsense()", timeout * 60000 );
var myTime = new Date();
this.lastupdate = myTime.getTime();
}
AdsenseNotifier.prototype.save_prefs = function() {
if ( this.Interval ) {
clearInterval( this.Interval );
}
try {
this._prefs.setCharPref( "username", document.getElementById( "adsenseUsername" ).value );
this.set_password( document.getElementById( "adsensePassword" ).value );
this._prefs.setIntPref( "updateinterval", ( ( document.getElementById( "adsenseUpdateInterval" ).value >= 10 ) ? document.getElementById( "adsenseUpdateInterval" ).value : 10 ) );
this._prefs.setIntPref( "openin", document.getElementById( "adsenseOpenin" ).value );
this._prefs.setBoolPref( "show_impressions", document.getElementById( "adsenseShowImpressions" ).checked );
this._prefs.setBoolPref( "show_clicks", document.getElementById( "adsenseShowClicks" ).checked );
this._prefs.setBoolPref( "show_ctr", document.getElementById( "adsenseShowCTR" ).checked );
this._prefs.setBoolPref( "show_cpm", document.getElementById( "adsenseShowCPM" ).checked );
this._prefs.setBoolPref( "show_earnings", document.getElementById( "adsenseShowEarnings" ).checked );
this._prefs.setIntPref( "sort_by", document.getElementById( "adsenseSortBy" ).value );
this._prefs.setIntPref( "group_by", document.getElementById( "adsenseGroupBy" ).value );
this._prefs.setIntPref( "product", document.getElementById( "adsenseProduct" ).value );
} catch( err ) {}
this.load_prefs();
// this.query_adsense();
}
AdsenseNotifier.prototype.init_prefs = function() {
document.getElementById( "adsenseUsername" ).value = this.username;
document.getElementById( "adsensePassword" ).value = this.password;
document.getElementById( "adsenseUpdateInterval" ).value = this.updateinterval;
document.getElementById( "adsenseOpenin" ).value = this.openin;
document.getElementById( "adsenseShowImpressions" ).checked = this.show_impressions;
document.getElementById( "adsenseShowClicks" ).checked = this.show_clicks;
document.getElementById( "adsenseShowCTR" ).checked = this.show_ctr;
document.getElementById( "adsenseShowCPM" ).checked = this.show_cpm;
document.getElementById( "adsenseShowEarnings" ).checked = this.show_earnings;
document.getElementById( "adsenseSortBy" ).value = this.sort_by;
document.getElementById( "adsenseGroupBy" ).value = this.group_by;
document.getElementById( "adsenseProduct" ).value = this.product;
}
//AdsenseNotifier.prototype.httprequest = function( querystring , method, callback_onload, callback_parameters ) {
AdsenseNotifier.prototype.httprequest = function( args ) {
var self = this;
AdsenseOnload = function( request ) {
self._gXMLHttpRequest = request.target;
self.callback_onload( self.callback_parameters );
}
if ( args.method == null ) {
args.method = 'GET';
}
this._gXMLHttpRequest = new XMLHttpRequest();
if ( args.callback_onload ) {
this.callback_onload = args.callback_onload;
this.callback_parameters = args.callback_parameters;
this._gXMLHttpRequest.onload = AdsenseOnload;
}
this._gXMLHttpRequest.open( args.method, args.querystring );
this._gXMLHttpRequest.setRequestHeader( "User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3" );
if ( args.post_data ) {
this._gXMLHttpRequest.setRequestHeader( "Content-Type", "application/x-www-form-urlencoded" );
this._gXMLHttpRequest.send( args.post_data );
} else {
this._gXMLHttpRequest.send( null );
}
}
AdsenseNotifier.prototype.set_password = function( password ) {
var url = "chrome://adsense/";
try {
this._passwordManager.removeUser( url, "" );
} catch( err ){}
try {
this._prefs.setBoolPref( "pwupdate", !this.pwupdate );
this._passwordManagerInternal.addUserFull( url, "", password, "", "" );
} catch( err ){}
}
AdsenseNotifier.prototype.get_password = function () {
var url = "chrome://adsense/";
var host = {value:""};
var user = {value:""};
var password = {value:""};
try {
this._passwordManagerInternal.findPasswordEntry( url, "", "", host, user, password );
} catch( err ){}
return password.value;
}
AdsenseNotifier.prototype.open_adsense = function( destination ) {
if ( ( this.username == '' ) || ( this.password == '' ) ) {
loadPrefWindow();
} else {
var querystring = "https://www.google.com/adsense/home"
if ( this.openin == 3 ) {
window.open( querystring );
} else if ( ( this.openin == 1 ) || ( this.openin == 2 ) ) {
var mytab = this._browser.addTab( querystring );
if ( this.openin == 1 ) {
this._browser.selectedTab = mytab;
}
} else {
this._browser.loadURI( querystring );
}
}
}
AdsenseNotifier.prototype.query_adsense = function( Event ) {
this.load_prefs();
if ( ( this.username == '' ) || ( this.password == '' ) ) {
loadPrefWindow();
} else {
var product = get_product( this.product );
var sort_by = get_sort_by( this.sort_by );
var group_by = get_group_by( this.group_by );
var destination1;
var destination2;
if ( product[0] == 'afc' ) {
destination1 = "https://www.google.com/adsense/report/aggregate?product=" + product[0] + "&dateRange.dateRangeType=simple&dateRange.simpleDate=" + sort_by + "&groupByPref=date&unitPref=" + group_by + "&reportType=property&null=Display+Report";
} else {
destination1 = "https://www.google.com/adsense/report/aggregate?product=" + product[0] + "&dateRange.dateRangeType=simple&dateRange.simpleDate=" + sort_by + "&groupByPref=date&reportType=property&null=Display+Report";
}
if ( product[1] ) {
destination2 = "https://www.google.com/adsense/report/aggregate?product=" + product[1] + "&dateRange.dateRangeType=simple&dateRange.simpleDate=" + sort_by + "&groupByPref=date&reportType=property&null=Display+Report";
}
if ( ( Event ) && ( Event.button == 2 ) ) {
if ( this.openin == 4 ) {
loadPrefWindow();
} else {
this.open_adsense( destination1 );
}
return;
} else {
this.httprequest( { "querystring" : destination1, "callback_onload" : this.getEarnings, "callback_parameters" : { "destination1" : destination1, "destination2" : destination2 } } );
}
}
}
function get_product( iProduct ) {
var product;
var addproduct;
switch ( iProduct ) {
case 1:
product = "afs";
break;
case 2:
product = "afc";
addproduct = 'afs';
break;
default:
product = "afc";
break;
}
return( [ product, addproduct ] );
}
function get_sort_by( iSort_by ) {
var sort_by;
switch ( iSort_by ) {
case 1:
sort_by = "last7days";
break;
case 2:
sort_by = "thismonth";
break;
case 3:
sort_by = "alltime";
break;
case 4:
sort_by = "yesterday";
break;
case 5:
sort_by = "twodaysago";
break;
case 6:
sort_by = "lastmonth";
break;
case 7:
sort_by = "thisweek";
break;
case 8:
sort_by = "lastweek";
break;
case 9:
sort_by = "lastbusinessweek";
break;
default:
sort_by = "today";
break;
}
return( sort_by );
}
function get_group_by( iGroup_by ) {
var group_by;
switch ( iGroup_by ) {
case 0:
group_by = "page";
break;
case 1:
group_by = "adunit";
break;
}
return( group_by );
}
AdsenseNotifier.prototype.getEarnings = function( args ) {
if ( this.login( args ) ) {
var aMatches = new Array();
var response1 = this._gXMLHttpRequest.responseText;
aMatches = this.findEarnings( response1 );
if ( args.destination2 ) {
if ( args.responseText ) {
aMatches = this.findEarnings( args.responseText, aMatches );
aMatches[2] = ( aMatches[1] / aMatches[0] ) * 100;
aMatches[3] = ( aMatches[4] / aMatches[0] ) * 1000;
args.responseText = '';
this.update_statusbar( aMatches.slice( 0, 5 ) );
} else {
args.responseText = response1;
this.httprequest( { "querystring" : args.destination2, "callback_onload" : this.getEarnings, "callback_parameters" : args } );
}
} else {
this.update_statusbar( aMatches.slice( 0, 5 ) );
}
}
}
AdsenseNotifier.prototype.findEarnings = function( responseText, aMatches2 ) {
var re = new RegExp();
re.compile( '
\\s*(?:USD|US)?\\$?\\s?([(?:\\s(?!\\s))\\d\\.,]*)%?\\s?(?:USD)?\\s* | ', 'ig' );
var aMatches = new Array();
var cnt = 0;
var match = re.exec( responseText );
if ( match ) {
while ( ( match ) && ( cnt <= 4 ) ) {
var temp_match = remove_commas( match[1] );
if ( aMatches2 ) {
aMatches.push( parseFloat( temp_match ? temp_match : 0 ) + parseFloat( aMatches2[cnt] ? aMatches2[cnt] : 0 ) );
} else {
aMatches.push( parseFloat( temp_match ) );
}
match = re.exec( responseText );
cnt++;
}
return( aMatches );
} else {
if ( aMatches2 ) {
return( aMatches2 );
} else {
return( aMatches );
}
}
}
AdsenseNotifier.prototype.login = function( args ) {
if ( this._gXMLHttpRequest ) {
var re = /