Skip to content

Commit

Permalink
Simplify string comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
proginosko committed Dec 18, 2017
1 parent d11fd46 commit a0ed795
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ function checkTab(id, url, isRepeat) {
for (let set = 1; set <= NUM_SETS; set++) {
// Get regular expressions for matching sites to block/allow
let blockRE = gOptions[`blockRE${set}`];
if (blockRE == "") continue; // no block for this set
if (!blockRE) continue; // no block for this set
let allowRE = gOptions[`allowRE${set}`];
let keywordRE = gOptions[`keywordRE${set}`];

Expand Down Expand Up @@ -292,7 +292,7 @@ function checkTab(id, url, isRepeat) {

// Check time periods
let secsLeftBeforePeriod = Infinity;
if (onSelectedDay && times != "") {
if (onSelectedDay && times) {
// Get number of minutes elapsed since midnight
let mins = timedate.getHours() * 60 + timedate.getMinutes();

Expand All @@ -312,7 +312,7 @@ function checkTab(id, url, isRepeat) {

// Check time limit
let secsLeftBeforeLimit = Infinity;
if (onSelectedDay && limitMins != "" && limitPeriod != "") {
if (onSelectedDay && limitMins && limitPeriod) {
// Compute exact seconds before this time limit expires
secsLeftBeforeLimit = limitMins * 60;
if (timedata[2] == periodStart) {
Expand Down Expand Up @@ -476,7 +476,7 @@ function updateTimeData(url, secsOpen, secsFocus) {
for (let set = 1; set <= NUM_SETS; set++) {
// Get regular expressions for matching sites to block/allow
let blockRE = gOptions[`blockRE${set}`];
if (blockRE == "") continue; // no block for this set
if (!blockRE) continue; // no block for this set
let allowRE = gOptions[`allowRE${set}`];

// Test URL against block/allow regular expressions
Expand Down Expand Up @@ -685,7 +685,7 @@ function getUnblockTime(set) {
}

let timePeriods = (times != "");
let timeLimit = (limitMins != "" && limitPeriod != "");
let timeLimit = (limitMins && limitPeriod);

if (timePeriods && !timeLimit) {
// Case 1: within time periods (no time limit)
Expand Down
2 changes: 1 addition & 1 deletion blocked.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function processBlockInfo(info) {

let blockedSet = document.getElementById("leechblockBlockedSet");
if (info.blockedSet && info.blockedSetName && blockedSet) {
if (info.blockedSetName != "") {
if (info.blockedSetName) {
blockedSet.innerText = info.blockedSetName;
} else {
blockedSet.innerText += " " + info.blockedSet;
Expand Down

0 comments on commit a0ed795

Please sign in to comment.