Skip to content

Commit

Permalink
Fixed aggressive list and blacklist
Browse files Browse the repository at this point in the history
Fixes regression introduced in 90440b7
  • Loading branch information
Gofake1 committed Jul 9, 2017
1 parent 9df5460 commit 7d43076
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
18 changes: 7 additions & 11 deletions Nightlight.safariextension/nightlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Color(r, g, b, a) {
this.isTransparent = function() {
return this.a === 0;
};
/// Return saturation from HSV color model
/// Returns saturation from HSV color model
this.saturation = function() {
var max = Math.max(this.r, Math.max(this.g, this.b));
var min = Math.min(this.r, Math.min(this.g, this.b));
Expand Down Expand Up @@ -144,12 +144,10 @@ function makeWebpageColors(element) {
) {
if (oldBgColor.isColorful()) {
newBgColor = oldBgColor.shade(-20);
} else if (oldBgColor.isLight()) {
newBgColor = oldBgColor.invert();
} else {
if (oldBgColor.isLight()) {
newBgColor = oldBgColor.invert();
} else {
newBgColor = oldBgColor.shade(-50);
}
newBgColor = oldBgColor.shade(-50);
}
WEBPAGE_COLORS.bgColors.set(
oldBgColor.rgbString(), newBgColor.rgbString()
Expand Down Expand Up @@ -234,15 +232,14 @@ function nightlight(mode, element) {
}
element.style.backgroundImage = 'none';
element.style.setProperty('background-color', newBgColor.rgbString(), 'important');
element.style.color = newTextColor.rgbString();
element.style.setProperty('color', newTextColor.rgbString(), 'important');
break;
case 'CANVAS':
if (IS_AGGRESSIVE) {
element.parentNode.removeChild(element);
}
break;
case 'IMG':
element.style.backgroundColor = GrayColor();
if (DARKEN_IMAGES) {
element.style.filter = 'brightness(70%)';
}
Expand All @@ -257,13 +254,12 @@ function nightlight(mode, element) {
case 'DIV':
case 'SPAN':
if (IS_AGGRESSIVE) {
if (style.borderWidth != '0px') {
element.style.borderColor = newTextColor.rgbString();
}
element.style.borderWidth = '0px';
} else if (style.backgroundImage != 'none') {
return;
}
element.style.setProperty('background-color', newBgColor.rgbString(), 'important');
element.style.borderColor = newTextColor.rgbString();
if (!newBgColor.isLight()) {
element.style.color = newTextColor.rgbString();
}
Expand Down
21 changes: 11 additions & 10 deletions Nightlight.safariextension/popover.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
</head>

<body>
<input id="isOnCheckbox" type="checkbox" onchange="handleIsOn(this)">Nightlight <span id="nightlightStatus" class="gray"></span><br>
<input id="isOnCheckbox" type="checkbox" tabindex="-1" onchange="handleIsOn(this)">Nightlight <span id="nightlightStatus" class="gray"></span><br>
<div id="moreSettingsContainer">
<button id="moreSettingsButton" class="blue centered textButton" onclick="handleMoreSettingsVisibility()">More Settings</button>
<button id="moreSettingsButton" class="blue centered textButton" tabindex="-1" onclick="handleMoreSettingsVisibility()">More Settings</button>
<div id="moreSettings">
<input id="ignoreTabCheckbox" type="checkbox" onchange="handleIgnoreTab(this)"><span id="ignoreTabLabel">Ignore Tab</span><br>
<button id="aggressiveButton" class="red centered textButton" onclick="handleAggressive()">Aggressive</button><br>
<input id="ignoreTabCheckbox" type="checkbox" tabindex="-1" onchange="handleIgnoreTab(this)"><span id="ignoreTabLabel">Ignore Tab</span><br>
<button id="aggressiveButton" class="red centered textButton" tabindex="-1" onclick="handleAggressive()">Aggressive</button><br>
</div>
</div>
<hr>
Expand All @@ -51,14 +51,15 @@
<script>
var AGGRESSIVE_LIST = [];
if (safari.extension.settings.aggressiveList !== undefined) {
safari.extension.settings.aggressiveList.split(',');
AGGRESSIVE_LIST = safari.extension.settings.aggressiveList.split(',');
}
var AGGRESSIVE_TABS = new Set();
var BLACKLIST = [];
if (safari.extension.settings.blacklist !== undefined) {
safari.extension.settings.blacklist.split(',');
BLACKLIST = safari.extension.settings.blacklist.split(',');
}
var AGGRESSIVE_TABS = new Set();
var IGNORED_TABS = new Set();
var TAB_COLORS = {};
var WARNING = {
NOT_WEBPAGE: "This is not a webpage and won't be modified.",
BLACKLISTED: "This page is blacklisted and won't be modified.",
Expand Down Expand Up @@ -101,12 +102,12 @@
}

function renderColorGrid(colors) {
if (colors === null) {
return;
}
while (ColorGrid.firstChild) {
ColorGrid.removeChild(ColorGrid.firstChild);
}
if (colors === null) {
return;
}

var colorTable = document.createElement('table');
var colorRow, colorWell;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ Install from source using the [Extension Builder](https://developer.apple.com/li
Install from source using [developer mode](https://developer.chrome.com/extensions/getstarted#unpacked), or get it from the <s>[Chrome Store]()</s>.

#### Mobile
Try out the [bookmarklet](https://gofake1.net/projects/nightlight.html#bookmarklet)
Try out the [bookmarklet](https://gofake1.net/projects/nightlight.html#bookmarklet).

*This project is available under the MIT License.*

0 comments on commit 7d43076

Please sign in to comment.