diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9bea433
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+
+.DS_Store
diff --git a/out/RedirectTube-1.0.0.xpi b/out/RedirectTube-1.0.0.xpi
new file mode 100644
index 0000000..b34d637
Binary files /dev/null and b/out/RedirectTube-1.0.0.xpi differ
diff --git a/src/background.html b/src/background.html
new file mode 100644
index 0000000..8d62ea7
--- /dev/null
+++ b/src/background.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+ background.js
+
+
+
+
+
\ No newline at end of file
diff --git a/src/background.js b/src/background.js
new file mode 100644
index 0000000..5a201e0
--- /dev/null
+++ b/src/background.js
@@ -0,0 +1,43 @@
+chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
+ detectYT(changeInfo);
+});
+
+chrome.tabs.onActivated.addListener(function(activeInfo) {
+ chrome.tabs.get(activeInfo.tabId, function(tab) {
+ detectYT(tab);
+ });
+});
+
+function detectYT(changeInfo) {
+ openedUrl = changeInfo.url;
+ if (openedUrl) {
+ if (openedUrl.startsWith("https://www.youtube.com/watch?v=")) {
+ chrome.action.setIcon({ path: "img/icns/normal/64.png" });
+ } else {
+ chrome.action.setIcon({ path: "img/icns/grey/64.png" });
+ }
+ }
+}
+
+chrome.contextMenus.create({
+ id: "openInFreeTube",
+ title: "Open in FreeTube",
+ contexts: ["link"],
+ targetUrlPatterns: [
+ "*://www.youtube.com/*",
+ "*://youtube.com/*",
+ "*://youtu.be/*"
+ ]
+});
+
+chrome.contextMenus.onClicked.addListener((info, tab) => {
+ if (info.menuItemId === "openInFreeTube" && info.linkUrl) {
+ let newUrl = "freetube://" + info.linkUrl;
+ if (newUrl.includes("youtu.be")) {
+ const videoId = newUrl.split("/").pop();
+ newUrl = `freetube://https://www.youtube.com/watch?v=${videoId}`;
+ }
+ chrome.tabs.update({ url: newUrl });
+ console.log(newUrl);
+ }
+});
\ No newline at end of file
diff --git a/src/img/icns/grey/64.png b/src/img/icns/grey/64.png
new file mode 100644
index 0000000..5dcfb2f
Binary files /dev/null and b/src/img/icns/grey/64.png differ
diff --git a/src/img/icns/normal/128.png b/src/img/icns/normal/128.png
new file mode 100644
index 0000000..1a8fd76
Binary files /dev/null and b/src/img/icns/normal/128.png differ
diff --git a/src/img/icns/normal/16.png b/src/img/icns/normal/16.png
new file mode 100644
index 0000000..3b7820a
Binary files /dev/null and b/src/img/icns/normal/16.png differ
diff --git a/src/img/icns/normal/256.png b/src/img/icns/normal/256.png
new file mode 100644
index 0000000..14218dc
Binary files /dev/null and b/src/img/icns/normal/256.png differ
diff --git a/src/img/icns/normal/32.png b/src/img/icns/normal/32.png
new file mode 100644
index 0000000..c5e7458
Binary files /dev/null and b/src/img/icns/normal/32.png differ
diff --git a/src/img/icns/normal/48.png b/src/img/icns/normal/48.png
new file mode 100644
index 0000000..dbc4d99
Binary files /dev/null and b/src/img/icns/normal/48.png differ
diff --git a/src/img/icns/normal/512.png b/src/img/icns/normal/512.png
new file mode 100644
index 0000000..a8abc93
Binary files /dev/null and b/src/img/icns/normal/512.png differ
diff --git a/src/img/icns/normal/64.png b/src/img/icns/normal/64.png
new file mode 100644
index 0000000..5a200dd
Binary files /dev/null and b/src/img/icns/normal/64.png differ
diff --git a/src/img/icns/normal/96.png b/src/img/icns/normal/96.png
new file mode 100644
index 0000000..88eb054
Binary files /dev/null and b/src/img/icns/normal/96.png differ
diff --git a/src/manifest.json b/src/manifest.json
new file mode 100644
index 0000000..8409311
--- /dev/null
+++ b/src/manifest.json
@@ -0,0 +1,39 @@
+{
+ "name": "RedirectTube",
+ "description": "Open YouTube links in FreeTube",
+ "author": "MichaĆ Stankiewicz",
+ "version": "1.0.0",
+ "manifest_version": 3,
+ "icons": {
+ "16": "img/icns/normal/16.png",
+ "32": "img/icns/normal/32.png",
+ "48": "img/icns/normal/48.png",
+ "64": "img/icns/normal/64.png",
+ "96": "img/icns/normal/96.png",
+ "128": "img/icns/normal/128.png",
+ "256": "img/icns/normal/256.png",
+ "512": "img/icns/normal/512.png"
+ },
+ "background": {
+ "page": "background.html"
+ },
+ "permissions": [
+ "storage",
+ "tabs",
+ "activeTab",
+ "contextMenus"
+ ],
+ "action": {
+ "default_popup": "popup.html"
+ },
+ "host_permissions": [
+ "http://*/*",
+ "https://*/*"
+ ],
+ "browser_specific_settings": {
+ "gecko": {
+ "id": "redirecttube@stankiewiczm.eu",
+ "strict_min_version": "109.0"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/popup.html b/src/popup.html
new file mode 100644
index 0000000..5401682
--- /dev/null
+++ b/src/popup.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/popup.js b/src/popup.js
new file mode 100644
index 0000000..cb3c072
--- /dev/null
+++ b/src/popup.js
@@ -0,0 +1,18 @@
+var errorText = document.getElementById("errorText");
+
+function openInFreeTube() {
+ chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
+ var url = tabs[0].url;
+ if (url.startsWith("https://www.youtube.com/watch?v=")) {
+ var freeTubeUrl = "freetube://" + url;
+ chrome.tabs.update(tabs[0].id, {url: freeTubeUrl});
+ window.close();
+ } else {
+ errorText.innerHTML = "Cannot open this page in FreeTube.";
+ }
+ });
+}
+
+document.addEventListener('DOMContentLoaded', function() {
+ openInFreeTube();
+});
\ No newline at end of file