commit 03ac2037861bc21fab3022da954e7b4bb9ec37f4 Author: Ambrose Chua Date: Sun Oct 17 00:02:59 2021 +0800 Initial MV3 diff --git a/background.js b/background.js new file mode 100644 index 0000000..3f3e407 --- /dev/null +++ b/background.js @@ -0,0 +1,28 @@ +async function getCurrentTab() { + let queryOptions = { active: true, currentWindow: true }; + let [tab] = await chrome.tabs.query(queryOptions); + return tab; +} + +chrome.runtime.onInstalled.addListener(() => { + chrome.contextMenus.create({ + title: 'Make Gather fullscreen', + type: 'normal', + documentUrlPatterns: ["https://gather.town/app/*"], + id: 'make-fullscreen', + }); +}); + +chrome.contextMenus.onClicked.addListener(async (data) => { + if (data.menuItemId === 'make-fullscreen') { + const tab = await getCurrentTab(); + await chrome.scripting.insertCSS({ + target: { tabId: tab.id }, + files: ['inject.css'], + }); + await chrome.scripting.executeScript({ + target: { tabId: tab.id }, + files: ['inject.js'], + }); + } +}); diff --git a/inject.1080p.txt b/inject.1080p.txt new file mode 100644 index 0000000..cf073de --- /dev/null +++ b/inject.1080p.txt @@ -0,0 +1,5 @@ +window.innerWidth = 1920 + 72; +window.innerHeight = 1080; + +document.body.style.transform = 'translate(-72px, 0)'; +document.body.style.width = `${1920 + 72}px`; diff --git a/inject.css b/inject.css new file mode 100644 index 0000000..5b2f3a7 --- /dev/null +++ b/inject.css @@ -0,0 +1,12 @@ +body { + transform: translate(-72px, 0); + width: calc(100vw + 72px); +} + +/* Additional */ +.GameCanvasContainer-settings { + display: none; +} +.GameVideo-self-video-container { + display: none; +} diff --git a/inject.js b/inject.js new file mode 100644 index 0000000..12ddcbe --- /dev/null +++ b/inject.js @@ -0,0 +1,11 @@ +{ + const script = document.createElement('script'); + script.innerHTML = ` + window.innerWidth = window.outerWidth + 72; + window.innerHeight = window.outerHeight; + `; + document.head.appendChild(script); + + //document.body.style.transform = 'translate(-72px, 0)'; + //document.body.style.width = `${window.outerWidth + 72}px`; +} diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..d0f7a36 --- /dev/null +++ b/manifest.json @@ -0,0 +1,12 @@ +{ + "name": "Gather Fullscreen", + "description": "Click to show Gather in fullscreen", + "version": "1.0", + "permissions": ["contextMenus", "scripting"], + "host_permissions": ["https://gather.town/app/*"], + "background": { + "type": "module", + "service_worker": "background.js" + }, + "manifest_version": 3 +}