From 416b2d0d7496674c4f831c53d6e8d888e00461da Mon Sep 17 00:00:00 2001 From: fourtf Date: Wed, 30 May 2018 19:38:43 +0200 Subject: [PATCH] moved the browser extension into it's own repository --- browser_ext/.editorconfig | 19 ---- browser_ext/background.js | 217 -------------------------------------- browser_ext/icon.png | Bin 20070 -> 0 bytes browser_ext/inject.js | 180 ------------------------------- browser_ext/manifest.json | 33 ------ browser_ext/popup.html | 10 -- 6 files changed, 459 deletions(-) delete mode 100644 browser_ext/.editorconfig delete mode 100644 browser_ext/background.js delete mode 100644 browser_ext/icon.png delete mode 100644 browser_ext/inject.js delete mode 100644 browser_ext/manifest.json delete mode 100644 browser_ext/popup.html diff --git a/browser_ext/.editorconfig b/browser_ext/.editorconfig deleted file mode 100644 index 37346aa2f..000000000 --- a/browser_ext/.editorconfig +++ /dev/null @@ -1,19 +0,0 @@ -root = true - -[*] - -# Change these settings to your own preference -indent_style = space -indent_size = 2 - -# We recommend you to keep these unchanged -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false - -[Makefile] -indent_style = tab \ No newline at end of file diff --git a/browser_ext/background.js b/browser_ext/background.js deleted file mode 100644 index a87ca4859..000000000 --- a/browser_ext/background.js +++ /dev/null @@ -1,217 +0,0 @@ -const ignoredPages = { - "settings": true, - "payments": true, - "inventory": true, - "messages": true, - "subscriptions": true, - "friends": true, - "directory": true, -}; - -/// return channel name if it should contain a chat -function matchChannelName(url) { - if (!url) - return undefined; - - const match = url.match(/^https?:\/\/(www\.)?twitch.tv\/([a-zA-Z0-9_]+)\/?$/); - - let channelName; - if (match && (channelName = match[2], !ignoredPages[channelName])) { - return channelName; - } - - return undefined; -} - - -const appName = "com.chatterino.chatterino"; -let port = null; - -// gets the port for communication with chatterino -function getPort() { - if (port) { - return port; - } else { - // TODO: add cooldown - connectPort(); - - return port; - } -} - -/// connect to port -function connectPort() { - port = chrome.runtime.connectNative(appName); - console.log("port connected"); - let connected = true; - - port.onMessage.addListener(function (msg) { - console.log(msg); - }); - port.onDisconnect.addListener(function () { - console.log("port disconnected"); - - port = null; - }); - - let sendPing = () => { - if (connected) { - port.postMessage({ ping: true }); - } else { - setTimeout(sendPing, 5000); - } - } -} - - -// tab activated -chrome.tabs.onActivated.addListener((activeInfo) => { - chrome.tabs.get(activeInfo.tabId, (tab) => { - if (!tab || !tab.url) return; - - chrome.windows.get(tab.windowId, {}, (window) => { - if (!window.focused) return; - - if (window.state == "fullscreen") { - tryDetach(tab.windowId); - return; - } - - console.log("onActivated"); - onTabSelected(tab.url, tab); - }); - }); -}); - -// url changed -chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { - if (!tab.highlighted) - return; - - chrome.windows.get(tab.windowId, {}, (window) => { - if (!window.focused) return; - if (window.state == "fullscreen") { - tryDetach(tab.windowId); - return; - } - - console.log("onUpdated"); - onTabSelected(tab.url, tab); - }); -}); - -// tab detached -chrome.tabs.onDetached.addListener((tabId, detachInfo) => { - console.log("onDetached"); - tryDetach(detachInfo.oldWindowId); -}); - -// tab closed -chrome.windows.onRemoved.addListener((windowId) => { - console.log("onRemoved"); - tryDetach(windowId); -}); - -// window selected -chrome.windows.onFocusChanged.addListener((windowId) => { - console.log(windowId); - if (windowId == -1) return; - - // this returns all tabs when the query fails - chrome.tabs.query({ windowId: windowId, highlighted: true }, (tabs) => { - if (tabs.length === 1) { - let tab = tabs[0]; - - chrome.windows.get(tab.windowId, (window) => { - if (window.state == "fullscreen") { - tryDetach(tab.windowId); - return; - } - - console.log("onFocusChanged"); - onTabSelected(tab.url, tab); - }); - } - }); -}); - - -// attach or detach from tab -function onTabSelected(url, tab) { - let channelName = matchChannelName(url); - - if (channelName) { - // chrome.windows.get(tab.windowId, {}, (window) => { - // // attach to window - // tryAttach(tab.windowId, { - // name: channelName, - // yOffset: window.height - tab.height, - // }); - // }); - } else { - // detach from window - tryDetach(tab.windowId); - } -} - -// receiving messages from the inject script -chrome.runtime.onMessage.addListener((message, sender, callback) => { - console.log(message); - - // is tab highlighted - if (!sender.tab.highlighted) return; - - // is window focused - chrome.windows.get(sender.tab.windowId, {}, (window) => { - if (!window.focused) return; - if (window.state == "fullscreen") { - tryDetach(sender.tab.windowId); - return; - } - - // get zoom value - chrome.tabs.getZoom(sender.tab.id, (zoom) => { - let size = { - width: Math.floor(message.rect.width * zoom), - height: Math.floor(message.rect.height * zoom), - }; - - console.log(zoom); - - // attach to window - tryAttach(sender.tab.windowId, { - name: matchChannelName(sender.tab.url), - size: size, - }); - }); - }); -}); - - -// attach chatterino to a chrome window -function tryAttach(windowId, data) { - data.action = "select"; - data.attach = true; - data.type = "twitch"; - data.winId = "" + windowId; - - let port = getPort(); - - if (port) { - port.postMessage(data); - } -} - -// detach chatterino from a chrome window -function tryDetach(windowId) { - let port = getPort(); - - console.log("tryDetach"); - - if (port) { - port.postMessage({ - action: "detach", - winId: "" + windowId - }) - } -} diff --git a/browser_ext/icon.png b/browser_ext/icon.png deleted file mode 100644 index 9a6f5ba19b69347c6ae3d163995ec2f173b1de4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 20070 zcmX6^c|27A_r7B=*~ymBgh~>Mge;>4sVpT4p-)*-7}?jEiJ~a7MAosCHA@j$XC&FT ztQpMMcLswoX8GN|zdy#z^_qL<-t&H+bDrlp=e#jDHR9tw$_)SjpYio;cK`qaeuMyr zIKj6EUIotoj=b*}T>(maq?W(~c9+X0mjU2wED!xZ4)B=E^SZS+0Pr{edqG-}1&-i9 zC43C-`&b~Ief&^%%L%ufnZLEnjD@`%V8sN8NN&^gG;X>S%pieMsSU;&nmb_MtG2hOZjs36G%K zfN_$glJ&O}Y{$98FvpLcy#4M>;xE~xzxz0~j}@ufAA_GmawfGG0vlbBxVnn%Oz*ta z)!_P*SWDymM)mHkFg~RwtKzX)oX1lxl#TDXAN)sooJtX=xwH3I1YTQ?dc1r(EG@Wq z8F#A0U1(3=cEdyHS$4}a{?`)4Y2oeW+&%+E&VgE0i2D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 { - let lastRect = {}; - let port = null; - - let installedObjects = {}; - let rightCollapseButton = null; - let isCollapsed = false; - - const ignoredPages = { - "settings": true, - "payments": true, - "inventory": true, - "messages": true, - "subscriptions": true, - "friends": true, - "directory": true, - }; - - let findChatDiv = () => document.getElementsByClassName("right-column")[0]; - let findRightCollapse = () => document.getElementsByClassName("right-column__toggle-visibility")[0]; - let findRightColumn = () => document.getElementsByClassName("channel-page__right-column")[0]; - let findNavBar = () => document.getElementsByClassName("top-nav__menu")[0]; - - // logging function - function log(str) { - console.log("Chatterino Native: " + str); - } - - // install events - function installChatterino() { - log("trying to install events"); - - let retry = false; - - // right collapse button - if (!installedObjects.rightCollapse) { - retry = true; - - let x = findRightCollapse(); - - if (x != undefined) { - rightCollapseButton = x; - - x.addEventListener("click", () => { - let y = findChatDiv(); - - if (parseInt(y.style.width) == 0) { - y.style.width = "340px"; - isCollapsed = false; - } else { - y.style.width = 0; - isCollapsed = true; - } - }); - - installedObjects.rightCollapse = true; - } - } - - // right column - if (!installedObjects.rightColumn && installedObjects.rightCollapse) { - let x = findChatDiv(); - - if (x != undefined && x.children.length >= 2) { - x.children[0].innerHTML = "
" + - "Disconnected from the chatterino extension.

Please focus the window or refresh the page." + - "
"; - - installedObjects.rightColumn = true; - } else { - retry = true; - } - } - - // nav bar - if (!installedObjects.topNav) { - if (rightCollapseButton) { - let x = findNavBar(); - - x.addEventListener("mouseup", () => { - console.log(isCollapsed) - - if (!isCollapsed) { - let collapse = findRightCollapse(); - collapse.click(); - } - }); - - installedObjects.topNav = true; - } else { - retry = true; - } - } - - // retry if needed - if (retry) { - setTimeout(installChatterino, 1000); - } else { - log("installed all events"); - } - } - - // query the rect of the chat - function queryChatRect() { - if (!matchChannelName(window.location.href)) return; - - let element = findChatDiv(); - - if (element === undefined) { - log("failed to find chat div"); - return; - } - - let rect = element.getBoundingClientRect(); - - /* if ( - lastRect.left == rect.left && - lastRect.right == rect.right && - lastRect.top == rect.top && - lastRect.bottom == rect.bottom - ) { - // log("skipped sending message"); - return; - } */ - lastRect = rect; - - let data = { - rect: rect, - }; - - isCollapsed = rect.width == 0; - - try { - chrome.runtime.sendMessage(data); - } catch { - // failed to send a message to the runtime -> maybe the extension got reloaded - // alert("reload the page to re-enable chatterino native"); - } - } - - function queryChatRectLoop() { - let t1 = performance.now(); - queryChatRect(); - let t2 = performance.now(); - console.log("queryCharRect " + (t2 - t1) + "ms"); - // setTimeout(queryCharRectLoop, 500); - } - - // return channel name if it should contain a chat or undefined - function matchChannelName(url) { - if (!url) - return undefined; - - const match = url.match(/^https?:\/\/(www\.)?twitch.tv\/([a-zA-Z0-9_]+)\/?$/); - - let channelName; - if (match && (channelName = match[2], !ignoredPages[channelName])) { - return channelName; - } - - return undefined; - } - - - // event listeners - window.addEventListener("load", () => setTimeout(queryChatRect, 1000)); - window.addEventListener("resize", queryChatRect); - window.addEventListener("focus", queryChatRect); - window.addEventListener("mouseup", () => setTimeout(queryChatRect, 10)); - window.addEventListener("hashchange", () => { - installedObjects = {}; - installChatterino(); - }); - - // - log("hello there in the dev tools 👋"); - - queryChatRectLoop(); - installChatterino(); -})() diff --git a/browser_ext/manifest.json b/browser_ext/manifest.json deleted file mode 100644 index a3829d3c0..000000000 --- a/browser_ext/manifest.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "Chatterino", - "version": "1.0", - "description": "xd", - "permissions": [ - "tabs", - "nativeMessaging" - ], - "icons": { - "256": "icon.png" - }, - "manifest_version": 2, - "background": { - "scripts": [ - "background.js" - ], - "persistent": false - }, - "browser_action": { - "default_popup": "popup.html" - }, - "content_scripts": [ - { - "run_at": "document_end", - "matches": [ - "https://www.twitch.tv/*" - ], - "js": [ - "inject.js" - ] - } - ] -} diff --git a/browser_ext/popup.html b/browser_ext/popup.html deleted file mode 100644 index 221fc73e6..000000000 --- a/browser_ext/popup.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - -
- Chatterino extension :) -
- - -