forked from corollari/waspline-reader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement changes suggested in corollari#1
- Loading branch information
Showing
10 changed files
with
83 additions
and
28 deletions.
There are no files selected for viewing
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>WaspLineReader Options</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<style> | ||
.vertical-center { | ||
min-height: 100%; /* Fallback for browsers do NOT support vh unit */ | ||
min-height: 100vh; /* These two lines are counted as one :-) */ | ||
|
||
display: flex; | ||
align-items: center; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div> | ||
<h4>Options</h4> | ||
<div> | ||
<label for="gradientLength">Gradient length</label><br> | ||
<input type="range" name="gradientLength" min="0" max="100" id="lengthSlider"> | ||
<input type="number" min="0" max="100" id="percentSlider" value="50">% | ||
<p>All the settings are saved automatically when modified.<br>You can use this paragraph to test how modifying<br>the options affects the extension's behaviour.<br>Just change one of the options to see how it works. | ||
</p> | ||
</div> | ||
<br> | ||
<hr> | ||
<br> | ||
<strong>Issues and feature requests</strong>: Create a github issue at <a href="https://github.com/corollari/waspline-reader/issues">github.com/corollari/waspline-reader</a> or send an email to the developer (<a href="mailto:[email protected]">[email protected]</a>) | ||
</div> | ||
</div> | ||
|
||
<script src="./options.js" type="module"></script> | ||
<script src="../contentScript.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
let slider = document.querySelector("#lengthSlider"); | ||
let numBox = document.querySelector("#percentSlider"); | ||
slider.addEventListener("input", ()=>updateValue(slider.value)); | ||
numBox.addEventListener("input", ()=>updateValue(numBox.value)); | ||
chrome.storage.local.get(["GRADIENT_LENGTH_PERCENTAGE"], (result)=>updateValue((result["GRADIENT_LENGTH_PERCENTAGE"]||0.5)*100)); | ||
|
||
function updateValue(value){ | ||
numBox.value=value; | ||
slider.value=value; | ||
chrome.storage.local.set({"GRADIENT_LENGTH_PERCENTAGE": value/100}); | ||
applyGradient(value/100); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,37 @@ | ||
const GRADIENT_LENGTH_PERCENTAGE = 0.5; | ||
|
||
var ps = document.getElementsByTagName('p'); | ||
for(let i=0; i<ps.length; i++){ | ||
var p = ps[i]; | ||
var lines = lineWrapDetector.getLines(p); | ||
for(let j=0; j<lines.length; j++){ | ||
let line = lines[j]; | ||
let red = 0, blue = 0, green = 0; | ||
for(let k=0; k<line.length; k++){ | ||
switch(j%4){ | ||
case 0: //Blue ending | ||
blue = k>(line.length-1)*GRADIENT_LENGTH_PERCENTAGE ? getGradient(k, line.length) : 0; | ||
break; | ||
case 1: //Blue beginning | ||
blue = k<(line.length-1)*GRADIENT_LENGTH_PERCENTAGE ? getGradient(k, line.length) : 0; | ||
break; | ||
case 2: //Red ending | ||
red = k>(line.length-1)*GRADIENT_LENGTH_PERCENTAGE ? getGradient(k, line.length) : 0; | ||
break; | ||
case 3: //Red beginning | ||
red = k<(line.length-1)*GRADIENT_LENGTH_PERCENTAGE ? getGradient(k, line.length) : 0; | ||
break; | ||
function applyGradient(GRADIENT_LENGTH_PERCENTAGE){ | ||
var ps = document.getElementsByTagName('p'); | ||
for(let i=0; i<ps.length; i++){ | ||
var p = ps[i]; | ||
var lines = lineWrapDetector.getLines(p); | ||
for(let j=0; j<lines.length; j++){ | ||
let line = lines[j]; | ||
let red = 0, blue = 0, green = 0; | ||
for(let k=0; k<line.length; k++){ | ||
switch(j%4){ | ||
case 0: //Blue ending | ||
blue = k>(line.length-1)*(1-GRADIENT_LENGTH_PERCENTAGE) ? getGradient(k, line.length) : 0; | ||
break; | ||
case 1: //Blue beginning | ||
blue = k<(line.length-1)*GRADIENT_LENGTH_PERCENTAGE ? getGradient(k, line.length, true) : 0; | ||
break; | ||
case 2: //Red ending | ||
red = k>(line.length-1)*(1-GRADIENT_LENGTH_PERCENTAGE) ? getGradient(k, line.length) : 0; | ||
break; | ||
case 3: //Red beginning | ||
red = k<(line.length-1)*GRADIENT_LENGTH_PERCENTAGE ? getGradient(k, line.length, true) : 0; | ||
break; | ||
} | ||
line[k].style.color="rgb("+red+","+green+","+blue+")"; | ||
} | ||
line[k].style.color="rgb("+red+","+green+","+blue+")"; | ||
} | ||
} | ||
function getGradient(k, len, beginning){ | ||
return Math.round(Math.abs(255*((beginning?1:0)-(k-(len-1)*(1-GRADIENT_LENGTH_PERCENTAGE))/((len-1)*GRADIENT_LENGTH_PERCENTAGE)))); | ||
} | ||
} | ||
|
||
function getGradient(k, len){ | ||
return Math.round(Math.abs(255*(((k/(len-1))-GRADIENT_LENGTH_PERCENTAGE)/GRADIENT_LENGTH_PERCENTAGE))); | ||
try{ | ||
chrome.storage.local.get(["GRADIENT_LENGTH_PERCENTAGE"], (result)=>applyGradient(result["GRADIENT_LENGTH_PERCENTAGE"]||0.5)); | ||
} catch(e){ | ||
applyGradient(0.5); | ||
} |