Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video volume #18

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
24 changes: 19 additions & 5 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ for (let i = 0; i < fontStyleBtns.length; i++) {
)
}

const images = document.getElementsByClassName('img-remmover');
// Change Word Spacing
// const wordSpaceBtns = document.getElementByClassName('wordSpace');
// for (let i = 0; i < wordSpaceBtns.length; i++) {
// wordSpaceBtns[i].addEventListener('click', function (e) {
// chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
// chrome.tabs.sendMessage(tabs[0].id, {action: "wordSpace", wordSpace: e.target.innerText});
// }
// )
// }
// )
// }

const images = document.getElementsByClassName('img-remover');
for(let i = 0; i < images.length; i++) {
images[i].addEventListener('click', function (e) {
console.log("clicked")
Expand All @@ -38,7 +50,7 @@ for (let i = 0; i < imageAdd.length; i++) {
chrome.tabs.sendMessage(tabs[0].id, { action: "imageAdd" });
})
})
};
}

const textToSpeech = document.getElementsByClassName('text-to-speech');
const rate = document.querySelector('#rate');
Expand All @@ -64,6 +76,8 @@ for (let i = 0; i < textToSpeechStop.length; i++) {
)
}

// Raise Video Volume

const links = document.getElementsByClassName('link');
for (let i = 0; i < links.length; i++) {
links[i].addEventListener('click', function (e) {
Expand All @@ -72,7 +86,7 @@ for (let i = 0; i < links.length; i++) {
}
)
})
};
}

const removeLinkHighlight = document.getElementsByClassName('remove-link-hg');
for (let i = 0; i < links.length; i++) {
Expand All @@ -82,7 +96,7 @@ for (let i = 0; i < links.length; i++) {
}
)
})
};
}


const imageReader = document.getElementsByClassName('img-read');
Expand Down Expand Up @@ -134,7 +148,7 @@ for (let i = 0; i < highlightPara.length; i++) {
chrome.tabs.sendMessage(tabs[0].id, { action: "para-highlighter" });
})
})
};
}

const removeHighlightPara = document.getElementsByClassName('para-highlighter-remove');
for (let i = 0; i < removeHighlightPara.length; i++) {
Expand Down
187 changes: 187 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
const synth = window.speechSynthesis;

window.addEventListener("load", function load(event) {


window.removeEventListener("load", load, false);
chrome.runtime.onMessage.addListener(

function (request, sender, sendResponse) {
let backColor = '';
let fontColor = '';
let originalLineHeight = 1;

const action = request.action;
if (action === 'fontSize') {
//console.log(request.fontSize);
const fontSize = request.fontSize;
const html = document.querySelector('html');
html.style.fontSize = fontSize;
//console.log(html.innerText);
}
else if (action === 'fontStyle') {
console.log(request.fontStyle);
document.getElementsByTagName('body')[0].setAttribute('id', 'fonter');
const html = document.querySelector('#fonter');

if (request.fontStyle === 'Trebuchet MS') {
html.style.setProperty('font-family', 'Castellar, Trebuchet MS, sans-serif');
}
else if (request.fontStyle === 'Arial') {
html.style.setProperty('font-family', 'Arial, sans-serif');
}
else if (request.fontStyle === 'Baskerville') {
html.style.setProperty('font-family', 'Baskerville, serif');
}
else if (request.fontStyle === 'Calibri') {
html.style.setProperty('font-family', 'Calibri, sans-serif');
}
else if (request.fontStyle === 'Garamond') {
html.style.setProperty('font-family', 'Garamond, serif');
}
else if (request.fontStyle === 'Verdana') {
html.style.setProperty('font-family', 'Verdana, sans-serif');
}
}
// Change Word Spacing
// else if (action === 'wordSpace') {
// console.log(request.wordSpace);
// document.getElementsByTagName('body')[0].setAttribute('id', 'wspace');
// const html = document.querySelector('#wspace');

// if (request.wordSpace === 'Default') {
// document.getElementByTagName("body").style.wordSpacing = 'normal';
// }
// else if (request.wordSpace === '2x') {
// document.getElementByTagName("body").style.wordSpacing = '0.5em';
// }
// else if (request.wordSpace === '3x') {
// document.getElementByTagName("body").style.wordSpacing = '0.75em';
// }
// else if (request.wordSpace === '4x') {
// document.getElementByTagName("body").style.wordSpacing = '1em';
// }
// else if (request.wordSpace === '5x') {
// document.getElementByTagName("body").style.wordSpacing = '1.25em';
// }
// }
else if (action === 'image') {
const immgs = document.getElementsByTagName('img');
for (let i = 0; i < immgs.length; i++) {
immgs[i].style.setProperty('display', 'none');
}
}
else if (action === 'imageAdd') {
const immgs = document.getElementsByTagName('img');
for (let i = 0; i < immgs.length; i++) {
immgs[i].style.setProperty('display', 'block');
}
}

else if (action === 'text-to-speech') {
console.log('Hi');
if (synth.speaking) {
synth.cancel();
}
const text = document.getElementsByTagName('body')[0].innerText;
const msg = new SpeechSynthesisUtterance(text);
msg.rate = request.rate;
//console.log(msg);
synth.speak(msg);
}

// else if (action === 'stop-speech') {
// if (synth.speaking) {
// synth.cancel();
// }
// }

else if (action === 'link-highlight') {
const links = document.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
links[i].style.setProperty('background-color', 'yellow');
links[i].style.setProperty('fontSize', '24px');
}
}

else if (action === 'link-highlight-remove') {
const links = document.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
links[i].style.setProperty('background-color', 'transparent');
links[i].style.setProperty('fontSize', 'default');
}
}

else if (action === 'image-reader') {

const images = document.getElementsByTagName('img');
console.log(images)
for (let i = 0; i < images.length; i++) {
//read out alt text on mouse hover


images[i].addEventListener('mouseover', function (e) {
console.log("here")
console.log(images[i].alt);
const msg = new SpeechSynthesisUtterance(images[i].alt);
window.speechSynthesis.speak(msg);
});

//mouse exit
images[i].addEventListener('mouseleave', function (e) {
window.speechSynthesis.cancel();
});
}
}

else if (action === "backgroundColor") {
backColor === '' ? backColor = document.getElementsByTagName('body')[0].style.backgroundColor : null;
document.getElementsByTagName('body')[0].style.setProperty('background-color', request.backgroundColor);
}

else if (action === "revert-background-color") {
document.getElementsByTagName('body')[0].style.setProperty('background-color', backColor);
}

else if (action === "fontColor") {
console.log(request.fontColor);
fontColor === '' ? fontColor = document.getElementsByTagName('*')[0].style.fontColor : null;
const all = document.getElementsByTagName('*');
for (let i = 0; i < all.length; i++) {
all[i].style.setProperty('color', request.fontColor);
}
}

// else if (action === "revert-font-color") {
// const all = document.getElementsByTagName('*');
// for (let i = 0; i < all.length; i++) {
// all[i].style.setProperty('color', request.fontColor);
// }
// }



else if (action === "para-highlighter") {
const paras1 = document.getElementsByTagName('p');
const paras2 = document.getElementsByTagName('div');
const paras = [...paras1, ...paras2];
for (let i = 0; i < paras.length; i++) {
paras[i].style.setProperty('border', '2px solid yellow');
}
}

else if (action === "para-highlighter-remove") {
const paras1 = document.getElementsByTagName('p');
const paras2 = document.getElementsByTagName('div');
const paras = [...paras1, ...paras2];
for (let i = 0; i < paras.length; i++) {
paras[i].style.setProperty('border', 'none');
}
}


})
},false);



23 changes: 21 additions & 2 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,42 @@ <h1>FONT STYLE</h1>
<button class="fontStyle">Trebuchet MS</button>
<button class="fontStyle">Verdana</button>
</section>

<!-- <section>
<h1>WORD SPACING</h1>
<button class="wordSpace">Default</button>
<button class="wordSpace">2x</button>
<button class="wordSpace">3x</button>
<button class="wordSpace">4x</button>
<button class="wordSpace">5x</button>
</section> -->

<section>
<h1>IMAGES</h1>
<button class="img-remmover">Remove images</button>
<button class="img-remover">Remove images</button>

<button class="img-add">Add images</button>

<button class="img-read">Read Out Images</button>
</section>
<section>
<h1>LSITEN TO WEB PAGE</h1>
<h1>LISTEN TO WEB PAGE</h1>
<button class="text-to-speech">Speak</button>
<div id="rate-control">
<label for="rate">Rate:</label>
<input type="range" min="0.5" max="2" value="1" step="0.1" id="rate">
</div>
<!-- <button class="stop-speech">Stop</button> -->
</section>

<!-- <section>
<h1>RAISE VIDEO VOLUME</h1>
<button class="volumeAdjust">1x</button>
<button class="volumeAdjust">2x</button>
<button class="volumeAdjust">3x</button>
<button class="volumeAdjust">4x</button>
<button class="volumeAdjust">5x</button>
</section> -->

<section>
<h1>LINKS</h1>
Expand Down
94 changes: 94 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
*{
font-family: 'Courier New', Courier, monospace;
font-style: normal;
font-weight: 800;
font-size:26px;
word-spacing: normal;
}

.centered{
text-align: center;
width: 100%;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
}

body{
width: 500px;
/* use dyslexic friendly background */
background-color: rgba(0, 0, 0, 0.09) !important;
}

h1{
display: flex;
justify-content: center;
flex-direction: column;
width: 100%;
align-items: center;
}
button {
align-items: center;
background-color: #fee6e3;
border: 2px solid #111;
cursor: pointer;
border-radius: 8px;
box-sizing: border-box;
color: #111;
/* display: flex; */
margin:25px;
font-size: 16px;
height: 48px;
/* justify-content: center; */
line-height: 24px;
max-width: 100%;
padding: 0 25px;
position: relative;
/* text-align: center; */
text-decoration: none;
/* user-select: none; */
/* -webkit-user-select: none; */
/* touch-action: manipulation; */
}

button:after {
background-color: #111;
border-radius: 8px;
content: "";
display: block;
height: 48px;
left: 0;
width: 100%;
position: absolute;
top: -2px;
transform: translate(8px, 8px);
transition: transform .2s ease-out;
z-index: -1;
}

button:hover:after {
transform: translate(0, 0);
}

button:active {
background-color: #ffdeda;
outline: 0;
}

button:hover {
outline: 0;
}

@media (min-width: 768px) {
button {
padding: 0 40px;
}
}

#rate-control {
display: flex;
align-items: center;
gap: 1rem;
margin: 1rem 0;
}