Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chrome/content/itsalltext.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ var ItsAllText = function () {
extensions: 'Char',
hotkey: 'Char',
tracker_id: 'Char',
blacklist_domains: 'Char',
},

/**
Expand Down
27 changes: 25 additions & 2 deletions src/chrome/content/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,33 @@ Monitor.prototype.isHTML = function (doc) {
is_html = (contentType == 'text/html' ||
contentType == 'text/xhtml' ||
contentType == 'application/xhtml+xml');

var blacklisted_domains = itsalltext.preferences.blacklist_domains.split("\n");
var pattern,
domain_is_blacklisted = false;
Copy link
Owner

@docwhat docwhat Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a separate method? And it should probably be called something like isDomainBlacklisted() take a domain as a string.

In theory, I should be writing tests for this stuff, but it wasn't really a thing when I started this project.

for(var i=0, len=blacklisted_domains.length; i<len; i++)
{
pattern = new RegExp( blacklisted_domains[i] );
if( pattern.test( doc.domain ) )
{
domain_is_blacklisted = true;
break;
}
}

/*
var console = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the built-in IAT debugging stuff... there are examples around here someplace.

if(domain_is_blacklisted)
{
console.logStringMessage( 'blacklisted: ' + doc.domain );
}
*/

is_usable = is_html &&
location &&
location.protocol !== 'about:' &&
location.protocol !== 'chrome:';
location.protocol !== 'about:' &&
location.protocol !== 'chrome:' &&
!domain_is_blacklisted;
try {
is_my_readme = location && location.href == itsalltext.README;
/*
Expand Down
8 changes: 8 additions & 0 deletions src/chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
name="extensions.itsalltext.fade_time" type="string" />
<preference id="pref_hotkey"
name="extensions.itsalltext.hotkey" type="string" />
<preference id="pref_blacklist_domains"
name="extensions.itsalltext.blacklist_domains" type="string" />
<preference id="pref_debug"
name="extensions.itsalltext.debug" type="bool" />
</preferences>
Expand Down Expand Up @@ -124,6 +126,12 @@
<spacer />
</hbox>
</row>
<row align="baseline">
<label control="blacklist_domains"
value="&blacklist_domains.label;" />
<textbox preference="pref_blacklist_domains" id="blacklist_domains"
size="30" tabindex="12" multiline="true"/>
</row>
</rows>
</grid>
<vbox id="help" flex="1">
Expand Down
1 change: 1 addition & 0 deletions src/chrome/locale/en-US/preferences.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@
<!ENTITY gumdrop_position.lower_left "Lower Left">
<!ENTITY gumdrop_position.lower_right "Lower Right">
<!ENTITY fade_time.label "Duration of button fade">
<!ENTITY blacklist_domains.label "Domains to blacklist (accepts RegExp; one per line)">