diff --git a/extension/content-script.js b/extension/content-script.js index 5aa3c8eb..1aa0dc0a 100644 --- a/extension/content-script.js +++ b/extension/content-script.js @@ -1,695 +1,700 @@ /* Copyright (C) 2017 Kai Uwe Broulik Copyright (C) 2018 David Edmundson This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ var callbacks = {}; function addCallback(subsystem, action, callback) { if (!callbacks[subsystem]) { callbacks[subsystem] = {}; } callbacks[subsystem][action] = callback; } function sendMessage(subsystem, action, payload) { (chrome.extension.sendMessage || browser.runtime.sendMessage)({ subsystem: subsystem, action: action, payload: payload }); } function executeScript(script) { var element = document.createElement('script'); element.innerHTML = '('+ script +')();'; (document.body || document.head || document.documentElement).appendChild(element); // We need to remove the script tag after inserting or else websites relying on the order of items in // document.getElementsByTagName("script") will break (looking at you, Google Hangouts) element.parentNode.removeChild(element); } chrome.runtime.onMessage.addListener(function (message, sender) { // TODO do something with sender (check privilige or whatever) var subsystem = message.subsystem; var action = message.action; if (!subsystem || !action) { return; } if (callbacks[subsystem] && callbacks[subsystem][action]) { callbacks[subsystem][action](message.payload); } }); var storage = (IS_FIREFOX ? chrome.storage.local : chrome.storage.sync); storage.get(DEFAULT_EXTENSION_SETTINGS, function (items) { if (items.breezeScrollBars.enabled) { loadBreezeScrollBars(); } if (items.mpris.enabled) { loadMpris(); if (items.mprisMediaSessions.enabled) { loadMediaSessionsShim(); } } }); // BREEZE SCROLL BARS // ------------------------------------------------------------------------ // function loadBreezeScrollBars() { if (IS_FIREFOX) { return; } if (!document.head) { return; } // You cannot access cssRules for on a different domain. // Since our chrome-extension:// URL for a stylesheet would be, this can // lead to problems in e.g modernizr, so include the