forked from opt-out-tools/opt-out
-
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.
Merge pull request opt-out-tools#75 from opt-out-tools/ribicn-softerr…
…ific-update_to_tests_and_code Taking out selenium tests so we can merge the rest of the PR
- Loading branch information
Showing
21 changed files
with
1,040 additions
and
192 deletions.
There are no files selected for viewing
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
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
File renamed without changes
File renamed without changes
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,10 @@ | ||
/** | ||
* @description Display the popup's error message, and hide the normal UI. | ||
* | ||
* @param error - contains error message | ||
*/ | ||
export default function (error) { | ||
document.querySelector('#popup-content').classList.add('hidden'); | ||
document.querySelector('#error-content').classList.remove('hidden'); | ||
console.error(`Failed to execute opt-out content script: ${error.message}`); | ||
} |
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 @@ | ||
import updateSliderKnob from './updateSliderKnob.js'; | ||
|
||
/** | ||
* @description Updates slider and option states, from values provided by result, and sets them in popup | ||
* @param result {object} | ||
*/ | ||
export default function (result) { | ||
document.querySelector(`#${result.optOut.selector}`).checked = true; | ||
const slider = document.querySelector('#slider'); | ||
slider.value = result.optOut.slider; | ||
updateSliderKnob(slider); | ||
} |
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,8 @@ | ||
/** | ||
* @description Updates slider's knob css image depending on the current value | ||
* | ||
* @param slider | ||
*/ | ||
export default function (slider) { | ||
(slider.value === '1') ? slider.classList.remove('slider-angry') : slider.classList.add('slider-angry'); | ||
} |
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,37 @@ | ||
import updateOptions from './functions/updateOptions.js'; | ||
import onError from './functions/onError.js'; | ||
import updateSliderKnob from './functions/updateSliderKnob.js'; | ||
|
||
/** | ||
* @description get input values, send them to storage and send message for update to background | ||
* script | ||
* @param tabs | ||
*/ | ||
function setChecks(tabs) { | ||
const slider = document.getElementById('slider'); | ||
const optionValue = document.querySelector('input[name="text_options"]:checked').value || 'tc'; | ||
const popupSettings = { | ||
slider: slider.value, | ||
selector: optionValue, | ||
}; | ||
|
||
updateSliderKnob(slider); | ||
browser.storage.sync.set({ optOut: popupSettings }); | ||
browser.tabs.sendMessage(tabs[0].id, popupSettings); | ||
} | ||
|
||
/** | ||
* When the popup loads, inject a content script into the active tab, | ||
* and add a click handler. | ||
* If we couldn't inject the script, handle the error. | ||
*/ | ||
document.addEventListener('DOMContentLoaded', browser.storage.sync.get('optOut').then(updateOptions, onError)); | ||
document.addEventListener('input', () => { | ||
browser.tabs | ||
.query({ | ||
active: true, | ||
url: 'https://twitter.com/*', | ||
currentWindow: true, | ||
}) | ||
.then(setChecks, onError); | ||
}); |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.