first commit
This commit is contained in:
		
							
								
								
									
										17
									
								
								chrome/manifest.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								chrome/manifest.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
{
 | 
			
		||||
    "name": "Proxy Stream",
 | 
			
		||||
    "icons": {
 | 
			
		||||
        "16": "icon-16.png",
 | 
			
		||||
        "19": "icon-19.png",
 | 
			
		||||
        "38": "icon-38.png",
 | 
			
		||||
        "48": "icon-48.png",
 | 
			
		||||
        "128": "icon-128.png"
 | 
			
		||||
    },
 | 
			
		||||
    "version": "116.0",
 | 
			
		||||
    "manifest_version": 3,
 | 
			
		||||
    "permissions": ["tabs"],
 | 
			
		||||
    "action": {
 | 
			
		||||
        "default_title": "Proxy Stream",
 | 
			
		||||
        "default_popup": "popup.html"
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										9
									
								
								chrome/popup.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								chrome/popup.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,9 @@
 | 
			
		||||
<html>
 | 
			
		||||
    <head>
 | 
			
		||||
        <script src="script.js"></script>
 | 
			
		||||
        <title>Proxy Stream</title>
 | 
			
		||||
    </head>
 | 
			
		||||
    <body>
 | 
			
		||||
        <button>Proxy Stream</button>
 | 
			
		||||
    </body>
 | 
			
		||||
</html>
 | 
			
		||||
							
								
								
									
										33
									
								
								chrome/script.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								chrome/script.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
let providers = new Map();
 | 
			
		||||
providers.set("www.youtube.com", "youtube");
 | 
			
		||||
providers.set("youtube.com", "youtube");
 | 
			
		||||
providers.set("youtu.be", "youtube");
 | 
			
		||||
providers.set("tv.nrk.no", "nrk");
 | 
			
		||||
providers.set("nx12210.your-storageshare.de", "nextcloud");
 | 
			
		||||
 | 
			
		||||
document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
    let [button] = document.getElementsByTagName("button");
 | 
			
		||||
    button.addEventListener("click", (ev) => {
 | 
			
		||||
        chrome.tabs.query({currentWindow: true, active: true}, (tabs) => {
 | 
			
		||||
            let oldurl = new URL(tabs[0].url);
 | 
			
		||||
            let newurl = new URL("https://stream.purser.it");
 | 
			
		||||
            let search = new URLSearchParams();
 | 
			
		||||
            let hostname = oldurl.hostname.toLowerCase();
 | 
			
		||||
            if(providers.has(hostname)) {
 | 
			
		||||
                if(hostname.includes("youtube.com")) {
 | 
			
		||||
                    let newpath = oldurl.searchParams.get("v");
 | 
			
		||||
                    if((newpath instanceof String) || ((typeof newpath) === "string")) {
 | 
			
		||||
                        newurl.pathname = "/" + newpath;
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    newurl.pathname = oldurl.pathname;
 | 
			
		||||
                }
 | 
			
		||||
                search.append("provider", providers.get(hostname));
 | 
			
		||||
            }
 | 
			
		||||
            newurl.search = search.toString();
 | 
			
		||||
            let tab = {};
 | 
			
		||||
            tab.url = newurl.href;
 | 
			
		||||
            chrome.tabs.create(tab);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
		Reference in New Issue
	
	Block a user