Skip to content

Commit

Permalink
(Hopefully) Release 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stautonico committed Apr 2, 2022
1 parent cf0138e commit 6a47dc6
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
build/
23 changes: 23 additions & 0 deletions antishort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if (window.location.href.includes("youtube.com/shorts")) {
let currentUrl = window.location.href;
// Get the video ID from the URL
let splitLink = currentUrl.split('/');
let videoId;

for (let i = 0; i < splitLink.length; i++) {
if (splitLink[i] === "shorts") {
videoId = splitLink[i + 1];
break;
}
}

if (videoId === undefined) {
console.log("Anti-short: No video ID found.");
} else {
// Redirect to youtube.com/watch?v=videoId
let videoLink = "https://www.youtube.com/watch?v=" + videoId;
history.replaceState({}, 'Title', videoLink);
window.location.href = videoLink;
console.log(`Anti-short: Redirected to ${videoLink}`);
}
}
18 changes: 18 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const usingChrome = navigator.userAgent.indexOf('Chrome') > -1;

if (usingChrome) {
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.url) {
chrome.scripting.executeScript({
target: {tabId: tab.id},
files: ['antishort.js']
});
}
});
} else {
browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.url) {
browser.tabs.executeScript({file: 'antishort.js'});
}
});
}
24 changes: 24 additions & 0 deletions chrome_manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"manifest_version": 3,
"name": "Anti-Short",
"version": "1.0",
"version_name": "1.0 pre-release",
"description": "Stop using YouTube's short video player.",
"author": "Steve Tautonico",
"permissions": [
"tabs",
"scripting"
],
"host_permissions": [
"*://*.youtube.com/*"
],
"homepage_url": "https://github.com/stautonico/anti-short",
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"background": {
"service_worker": "background.js"
}
}
Binary file added images/base.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"manifest_version": 2,
"name": "Anti-Short",
"version": "1.0",
"description": "Stop using YouTube's short video player.",
"author": "Steve Tautonico",
"permissions": [
"tabs",
"*://*.youtube.com/*"
],
"homepage_url": "https://github.com/stautonico/anti-short",
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"background": {
"scripts": [
"background.js"
]
}
}
20 changes: 20 additions & 0 deletions package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
echo "Building package for Firefox..."

mkdir -p build/firefox build/chrome

zip -q -r build/firefox/antishort.xpi README.md manifest.json LICENSE images antishort.js background.js

echo -e "$(tput setaf 2)Successfully packaged for Firefox$(tput setaf 7)\n"

echo "Building package for Chrome..."

cp chrome_manifest.json build/chrome/manifest.json
cp -r images antishort.js background.js LICENSE README.md build/chrome

cd build/chrome
zip -q -r antishort.zip *
rm -rf images antishort.js background.js LICENSE README.md manifest.json


echo "$(tput setaf 2)Successfully packaged for Chrome"

0 comments on commit 6a47dc6

Please sign in to comment.