Skip to content

Commit

Permalink
🎉 Init
Browse files Browse the repository at this point in the history
  • Loading branch information
laurens94 committed Jun 7, 2023
0 parents commit b14c254
Show file tree
Hide file tree
Showing 15 changed files with 409 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false

[*.{js,ts,json}]
indent_size = 2
indent_style = space
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
"extends": "eslint:recommended",
"env": {
"browser": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2017
}
};
3 changes: 3 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

ko_fi: lauwerens
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
web-ext-artifacts
12 changes: 12 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"editor.formatOnSave": true,
"editor.tabSize": 2,
"eslint.validate": [
"javascript",
"typescript",
],
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"eslint.format.enable": true,
}
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/L3L0BR8QG)

# Video Seeking Everywhere
_A [Firefox](https://addons.mozilla.org/en-US/firefox/addon/video-seeking-everywhere/) extension that allows you to seek through any playing video on most websites using the < or > keys._

- Use <kbd><</kbd> or <kbd>,</kbd> to rewind with 5 seconds
- Use <kbd>></kbd> or <kbd>.</kbd> to seek forward with 5 seconds

🛠️ It's possible to change the amount of seconds using the Options page of this extension.

## Development
Please feel free to contribute by sending a Pull Request.

### Dependencies
You can either use `npm` or `pnpm` with the commands below or run `web-ext` directly:

### Running the extension
`pnpx web-ext run`

### Building
`pnpx web-ext build`

## Reference
See https://extensionworkshop.com/documentation/develop/getting-started-with-web-ext/ for information about the `web-ext` command.
8 changes: 8 additions & 0 deletions browser-polyfill.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions contentscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;
(function () {
const settings = {
rewindSec: 5,
seekForwardSec: 5
}

function onError(error) {
console.warn(`Could not load settings for Video Seeking Everywhere, falling back to defaults...`, error);
inject();
}

function onGot(item) {
if (item.rewindSec > 0) {
settings.rewindSec = item.rewindSec;
}
if (item.seekForwardSec > 0) {
settings.seekForwardSec = item.seekForwardSec;
}
inject()
}

let getting = browser.storage.sync.get();
getting.then(onGot, onError);

// Inject the script to the page:
function inject() {
var s = document.createElement('script');
s.src = chrome.runtime.getURL('video-seeking-everywhere.js?') + new URLSearchParams(settings);
s.onload = function () {
this.remove();
};
(document.head || document.documentElement).appendChild(s);
}
})()
Binary file added icons/128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions icons/video-seeking-everywhere.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"manifest_version": 3,
"name": "Video Seeking Everywhere",
"version": "1.0.0",
"description": "Allows you to seek through any playing video on most websites using the < or > keys.",
"icons": {
"48": "icons/128.png"
},
"content_scripts": [
{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"browser-polyfill.min.js",
"contentscript.js"
]
}
],
"web_accessible_resources": [
{
"resources": [
"video-seeking-everywhere.js"
],
"matches": [
"http://*/*",
"https://*/*"
]
}
],
"permissions": [
"storage"
],
"options_ui": {
"page": "options.html",
"open_in_tab": true
},
"browser_specific_settings": {
"gecko": {
"id": "@video-seeking-everywhere",
"strict_min_version": "109.0"
}
}
}
62 changes: 62 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Options for Video Seeking Everywhere</title>

<link rel="icon" href="./icons/video-seeking-everywhere.svg">
<link rel="stylesheet" href="./options/options.css">
<script type="application/javascript" src="browser-polyfill.min.js"></script>
<script src="./options/options.js" defer></script>
</head>

<body>
<div class="wrapper">
<fieldset>
<legend>
<h1 style="display: flex; align-items: center; gap: 1em;">
<img style="width: 2em; height: 2em;" src="./icons/video-seeking-everywhere.svg" alt="">
Options for Video Seeking Everywhere
</h1>
</legend>

<p>
Allows you to seek through any playing video on most websites using the <kbd>&lt;</kbd><kbd>&gt;</kbd> keys.
</p>

<p>
Use <kbd>&lt;</kbd> (or <kbd>,</kbd>) to rewind with <span data-rewind-sec>5</span> seconds<br>
Use <kbd>&gt;</kbd> (or <kbd>.</kbd>) to seek forward with <span data-forward-sec>5</span> seconds
</p>

<p>
You can change the amount of seconds to rewind or seek forward.
</p>

<form action="options.html" method="post">
<label for="rewind-seconds">Rewind Seconds
<input type="number" name="rewind-seconds" id="rewind-seconds" value="5" min="1">
</label>

<label for="forward-seconds">Forward Seconds
<input type="number" name="forward-seconds" id="forward-seconds" value="5" min="1">
</label>

<button type="reset" id="reset">Reset to defaults</button>
<button type="submit" id="save">Save</button>
</form>
</fieldset>

<div class="footer">
<a href="https://github.com/laurens94/video-seeking-everywhere" target="_blank" rel="noopener noreferrer">👨‍💻
Source Code</a>
<a href="https://github.com/laurens94/video-seeking-everywhere/issues/new" target="_blank"
rel="noopener noreferrer"><span>🐛 Report issue</span> &nbsp; <span>✨ Request feature</span></a>
<a href="https://ko-fi.com/lauwerens" target="_blank" rel="noopener noreferrer">☕ Buy me a coffee 🫶</a>
</div>
</div>
</body>

</html>
99 changes: 99 additions & 0 deletions options/options.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
font-family: sans-serif;
line-height: 1.5;
}

.wrapper {
max-width: 46rem;
margin: 2.5em auto;
}

p {
margin: .5em 0 2em;
}

.footer {
margin-top: 1em;
text-align: center;
display: flex;
justify-content: space-around;
}

kbd {
background-color: #eee;
border: 1px solid #ccc;
border-radius: 0.5em;
padding: 0.2em 0.5em;
font-size: 0.9em;
font-family: monospace;
margin: 0 0.2em;
box-shadow: 1px 1px 1px rgba(0, 0, 0, 0.2);
white-space: nowrap;
}

a {
text-decoration: none;
padding: .5em;
display: inline-block;
color: rgb(108, 128, 144);
border-radius: 0.5em;
}

a span {
white-space: nowrap;
}

a:hover {
background-color: black;
color: white;
}

fieldset {
border: 1px solid #ccc;
padding: 1em;
border-radius: 0.5em;
}

form {
display: grid;
flex-wrap: wrap;
gap: 2.5em;
justify-content: space-between;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

label {
font-weight: bold;
grid-column: span 1;
}

input {
display: block;
padding: 0.5em;
width: 100%;
border: 1px solid #ccc;
border-radius: 0.5em;
font-size: 1.2em;
}

button {
grid-column: span 1;
padding: 0.5em;
border: 1px solid #ccc;
border-radius: 0.5em;
}

button#save {
color: white;
background-color: rgb(51, 51, 51);
}

button#save:hover {
background-color: black;
}
Loading

0 comments on commit b14c254

Please sign in to comment.