commit b67a9ebbdf09cbbbad5ba62b6427baee8ef2dbe7 Author: Shane Lindsay Date: Thu Apr 8 03:43:22 2021 -0700 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/common/css/styles.css b/common/css/styles.css new file mode 100644 index 0000000..37780ba --- /dev/null +++ b/common/css/styles.css @@ -0,0 +1,68 @@ +html { + width: 300px; + height: 100px; + background: #151619; + color: #c9cbcd; + font-family: Open Sans,Segoe UI,sans-serif; + -webkit-font-smoothing: antialiased; + text-rendering: optimizeLegibility; +} + + +.container { + text-align: center; + padding-bottom: 10px; + } + + .button-group { + display: flex; + justify-content: center; + } + + .button { + border-radius: 6px; + color: #c3c4ca; + font-weight: bold; + padding: 10px 20px; + text-decoration: none; + transition: all 150ms ease-in-out; + } + .button:hover { + background-color: #1d1f23; + } + .button:not(:first-of-type) { + margin-left: 15px; + } + .button.bg-blue { + background-color: #202127; + color: #c3c4ca; + } + .button.bg-blue:hover { + background-color: #452e7c; + } + .discord { + overflow: visible; + margin-right: 3px; + display: inline-block; + } + .button-arrow .arrow-icon { + overflow: visible; + margin-left: 3px; + width: 8px; + } + .button-arrow .arrow-head { + transform: translateX(0); + transition: transform 150ms ease-in-out; + } + .button-arrow .arrow-body { + opacity: 0; + transform: scaleX(1); + transition: transform 150ms ease-in-out, opacity 150ms ease-in-out; + } + .button-arrow:hover .arrow-head { + transform: translateX(3px); + } + .button-arrow:hover .arrow-body { + opacity: 1; + transform: scaleX(2); + } \ No newline at end of file diff --git a/common/html/popup.html b/common/html/popup.html new file mode 100644 index 0000000..d0cdd55 --- /dev/null +++ b/common/html/popup.html @@ -0,0 +1,73 @@ + + + + + + + +
+
+ +
+ +
+ + + diff --git a/common/img/logo.png b/common/img/logo.png new file mode 100644 index 0000000..dff2826 Binary files /dev/null and b/common/img/logo.png differ diff --git a/common/img/ttvlol.png b/common/img/ttvlol.png new file mode 100644 index 0000000..8ca2117 Binary files /dev/null and b/common/img/ttvlol.png differ diff --git a/images/icon.png b/images/icon.png new file mode 100644 index 0000000..0ecc1ae Binary files /dev/null and b/images/icon.png differ diff --git a/js/background.js b/js/background.js new file mode 100644 index 0000000..af1549e --- /dev/null +++ b/js/background.js @@ -0,0 +1,31 @@ +function onBeforeRequest(details) { + const match = /hls\/(.+?)$/gim.exec(details.url); + + console.log("details:", details); + + if (match !== null && match.length > 1) { + return { + redirectUrl: `https://api.ttv.lol/playlist/${encodeURIComponent(match[1])}`, + }; + } +} + +chrome.webRequest.onBeforeRequest.addListener( + onBeforeRequest, + { urls: ["https://usher.ttvnw.net/api/channel/hls/*"] }, + ["blocking", "extraHeaders"] +); + +function onBeforeSendHeaders(req) { + console.log("onBeforeSendHeaders:", req.requestHeaders); + req.requestHeaders.push({name:'X-Donate-To', value:"http://bowlcuts-r-us.com"}) + return { + requestHeaders: req.requestHeaders + } +} + +chrome.webRequest.onBeforeSendHeaders.addListener( + onBeforeSendHeaders, + { urls: ["https://api.ttv.lol/playlist/*"] }, + ["blocking","requestHeaders"] +); \ No newline at end of file diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..ccb5050 --- /dev/null +++ b/manifest.json @@ -0,0 +1,23 @@ +{ + "background": { + "persistent": true, + "scripts": [ "js/background.js" ] + }, + "browser_action": { + "default_icon": { + "128": "images/icon.png" + }, + "default_popup": "common/html/popup.html", + "default_title": "TTV LOL" + }, + "description": "TTV LOL", + "icons": { + "128": "images/icon.png" + }, + "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx5wGmUxlKN2dFl5GB7BiqcDOrJhuFc6OAeuHhXsXRz8nBzETBDrDBaGrhHe/YDKUaEKA2rq2hGpXCuIa6/jHAnlYeeF0bnguOr13l+w3pFeVtp6VYEpZx0ZjegyVkhh4Dks6zdN7lrNUHM6nItS8Oa1n2YULE2r7aSiLFVT2MHBrVzPTUJHyqTnQkhga0UeIC60fJsJPwIEfSwi+xML97cOpEAlbtJTp/QLPaggh/5Iyfc92/pG2Yv5EhtqUWMpH+YviWF7WGosdxY0Z/b7gG0uE9HOLCq9Ism8CbP3VnW+8fz+iJiVVdyf2Nw3mt3jxr3jwfehfW6FwEzLmfDLFKwIDAQAB", + "manifest_version": 2, + "name": "TTV LOL", + "permissions": [ "webRequest", "webRequestBlocking", "https://*.twitch.tv/*", "https://usher.ttvnw.net/*", "cookies", "https://api.ttv.lol/playlist/*" ], + "update_url": "https://clients2.google.com/service/update2/crx", + "version": "2.2" +}