Search code examples
javascriptcssgoogle-chromegoogle-chrome-extensionfullscreen

Chrome Extension - Entering in FullScreen Mode turns the page background color to black


I am creating a Chrome Extension that allows the user to view any web page in full screen:

manifest.json

{
   "manifest_version": 2,
   "name": "...",
   "version": "1.0",
   "description": "...",
   "background": {
    "scripts": ["jf.js"]
   },
   "browser_action": {
    "default_icon": "icon.png",
    "default_title": "..."
   },
   "author": "..." ,
   "file_system_provider_capabilities":
  {
    "configurable": false
  },
   "incognito": "spanning",
   "offline_enabled": true,
   "permissions": [
     "tabs",
     "activeTab"
   ],
   "short_name": "..."
}

jf.js

chrome.browserAction.onClicked.addListener(function(tab) {
  chrome.tabs.insertCSS(null, {file: "jf.css"});
  chrome.tabs.executeScript({
    code: 'document.body.webkitRequestFullscreen()'
 });
});

jf.css

body:-webkit-full-screen {
 width: 100%;
 height: 100%;
 overflow: scroll;
}

It works fine but when a page goes into FullScreen Mode through the extension the background color of that same page becomes black, how can I solve that?

I used the FullScreen API described in: https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API in order to do this extension.

Thank You!


Solution

  • That might be just a bug from Google. You could try setting the background color of to the color it was before afterwards.