Only hide thumbnails during set timeframe#22
Conversation
Added "work mode" ability to only hide thumbnails during a set timeframe.
|
Question: Should this be part of the extension? tldr: Yes. It's in keeping with a key use case, and the downsides are not too great. For:
Against:
Alternatives:
|
domdomegg
left a comment
There was a problem hiding this comment.
Looks pretty good! A few changes requested, but concept is sound and most code good.
If you're busy, am happy to make the edits myself in the next couple of days.
| everywhere: false, | ||
| }, | ||
| thumbnailMode: 'hidden', | ||
| workMode: { |
There was a problem hiding this comment.
should: call this scheduledBlocking or timeBasedBlocking, or similar. On first glance I don't think I'd know what workMode means.
There was a problem hiding this comment.
must: Update the typedef on lines 9-18 to match (GitHub won't let me comment there). This ensures intellisense works as expected, and in future if we convert to TypeScript / run linters they'll pass.
You probably will want to merge in the master branch first, because I think there may be a few merge conflicts otherwise.
There was a problem hiding this comment.
consider: store this as an array of enabled times. This would allow users to set multiple periods where the extension is enabled, for example if they have a break in their work day or similar.
We don't actually have to accept more than one to start with, but I think it'd be good to design this so that if we do want to accept more than one in future people don't lose their settings. The options page would either:
- have an input as just a text field, where people can enter comma-separated ranges - format could be like LeechBlock (e.g.
0900-1700,1800-1900) or ISO8601-like format (e.g.09:00/17:00,18:00/19:00) - have pairs of time inputs, and users could click a
+icon to add more ranges
|
|
||
| elem.innerHTML = `/* Injected by the Hide YouTube Thumbnails extension */ | ||
| ${css[isDisabled ? 'normal' : options.thumbnailMode]}` | ||
| if(options.workMode.enabled){ |
There was a problem hiding this comment.
must: I think we can move this logic into the isDisabled check. For example, adding a condition like:
|| (options.workMode.enabled && !IsItWorkTime(options.workMode.startTime, options.workMode.endTime))
This significantly reduces code duplication and complexity.
| const elem = document.createElement("style"); | ||
| document.documentElement.appendChild(elem); | ||
|
|
||
| const IsItWorkTime = (startTime, endTime)=>{ |
There was a problem hiding this comment.
nit: use camel case for JS functions. Align naming with options if we're renaming to scheduledBlocking.
| const elem = document.createElement("style"); | ||
| document.documentElement.appendChild(elem); | ||
|
|
||
| const IsItWorkTime = (startTime, endTime)=>{ |
There was a problem hiding this comment.
praise: This logic looks sound and simple. I like it!
| <input type="checkbox" name="enableWorkMode" id="enableWorkMode"> | ||
| <label for="enableWorkMode" data-i18n="options_enable_work_mode">Enabled</label><br /> | ||
| <label for="workModeStart">Start date:</label> | ||
| <input type="time" id="workModeStart" name="workModeStart" > |
There was a problem hiding this comment.
praise: I like the use of the type="time" input!
| <label for="disableEverywhere" data-i18n="options_disable_extension_everywhere">Everywhere</label><br /> | ||
| <br /> | ||
|
|
||
| <p data-i18n="options_work_mode">Work Mode</p> |
There was a problem hiding this comment.
(update naming here if we're changing it to scheduledBlocking or similar)
| <label for="disableEverywhere" data-i18n="options_disable_extension_everywhere">Everywhere</label><br /> | ||
| <br /> | ||
|
|
||
| <p data-i18n="options_work_mode">Work Mode</p> |
There was a problem hiding this comment.
consider: Adding the strings to the en and es translation files in _locales. This makes things easier to translate in future.
If work mode is enabled:
if work mode is disabled:
Added "work mode" ability to only hide thumbnails during a set timeframe. Disabled by default, default time frame from 9am-5pm.
Please check the updateElem function, because I overrode the main functionality and would be open to a better way.