Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@

**Kiwi Browser, Yandex Browser, and other chrome-compatible browsers**

## Usage
You can toggle fullscreen mode by
* click extension icon
* using keyboard combination Alt + M


### Install from Chrome Web Store

* [Chrome Web Store: Fullscreen](https://chrome.google.com/webstore/detail/fullscreen/lbpgkagpackldbkfookmmdpfaolnoged)
Expand Down
16 changes: 16 additions & 0 deletions init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function injectCode(src) {
const script = document.createElement('script');
// This is why it works!
script.src = src;
script.onload = function() {
console.log("inpage script injected");
this.remove();
};

// This script runs before the <head> element is created,
// so we add the script to <html> instead.
document.documentElement.appendChild(script);
}


injectCode(chrome.runtime.getURL('/inpage.js'));
41 changes: 41 additions & 0 deletions inpage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
var altKeyPressed = false;

window.addEventListener('keydown', function(event) {
if (event.keyCode === 18) {
// The "Alt" key was pressed
altKeyPressed = true;
} else if (event.keyCode === 77 && altKeyPressed) {
// The "M" key was pressed while the "Alt" key was down
console.log('The "Alt + M" key combination was pressed');
if (document.fullscreenElement) {
// The current state is fullscreen
console.log('Currently in fullscreen mode');
var elem = document;
var rfs =
elem.exitFullscreen
|| elem.webkitExitFullScreen
|| elem.mozExitFullScreen
|| elem.msExitFullScreen;
rfs.call(elem);
} else {
// The current state is not fullscreen
console.log('Not currently in fullscreen mode');
var elem = document.documentElement;
var rfs =
elem.requestFullscreen
|| elem.webkitRequestFullScreen
|| elem.mozRequestFullScreen
|| elem.msRequestFullScreen;
rfs.call(elem);
}
}
});

window.addEventListener('keyup', function(event) {
if (event.keyCode === 18) {
// The "Alt" key was released
altKeyPressed = false;
}
});

console.log('Keyboard listener added for Alt+M')
27 changes: 26 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,35 @@
"name": "Fullscreen",
"version": "0.0.3",
"description": "Fullscreen extension for device without keyboard",
"permissions": ["activeTab", "scripting"],
"permissions": ["activeTab", "scripting", "tabs"],
"action": {
"default_title": "Click to fullscreen"
},
"content_scripts": [
{
"matches": [
"file://*/*",
"http://*/*",
"https://*/*"
],
"js": [
"init.js"
],
"run_at": "document_start",
"all_frames": true
}
],
"web_accessible_resources": [
{
"resources": [
"inpage.js"
],
"matches": [
"https://*/*",
"http://*/*"
]
}
],
"background":
{
"service_worker": "main.js"
Expand Down