Created
September 4, 2018 01:58
-
-
Save kane-c/56f550f7a081099bd2c034bf989053f5 to your computer and use it in GitHub Desktop.
BeardedSpice strategy to un/mute Google Meet via media keys/headphones button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// GoogleMeet.js | |
// BeardedSpice | |
// | |
// Created by @kane-c. | |
// Copyright (c) 2015-2017 GPL v3 http://www.gnu.org/licenses/gpl.html | |
// | |
// We put the copyright inside the plist to retain consistent syntax coloring. | |
BSStrategy = { | |
version: 1, | |
displayName: "Google Meet", | |
accepts: { | |
method: "predicateOnTab", | |
format: "%K LIKE[c] '*meet.google.com/*'", | |
args: ["URL"] | |
}, | |
isPlaying: function () { | |
var button = document.querySelector(".nod4rf .JRY2Pb"); | |
return button && button.getAttribute("data-is-muted") === "false"; | |
}, | |
toggle: function () { | |
function simulate(target, evtName) { | |
var evt = document.createEvent("MouseEvents"); | |
evt.initMouseEvent(evtName, true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, target); | |
target.dispatchEvent(evt); | |
} | |
function simulateClick(target) { | |
simulate(target, "mouseover"); | |
simulate(target, "mousedown"); | |
simulate(target, "mouseup"); | |
simulate(target, "mouseout"); | |
} | |
simulateClick(document.querySelector(".nod4rf .JRY2Pb"), "click"); | |
}, | |
previous: function () {}, | |
next: function () {}, | |
pause: function () { | |
var button = document.querySelector(".nod4rf .JRY2Pb"); | |
if (button.getAttribute("aria-pressed") === "false") { | |
function simulate(target, evtName) { | |
var evt = document.createEvent("MouseEvents"); | |
evt.initMouseEvent(evtName, true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, target); | |
target.dispatchEvent(evt); | |
} | |
function simulateClick(target) { | |
simulate(target, "mouseover"); | |
simulate(target, "mousedown"); | |
simulate(target, "mouseup"); | |
simulate(target, "mouseout"); | |
} | |
simulateClick(button, "click"); | |
} | |
}, | |
favorite: function () {}, | |
trackInfo: function () { | |
var pathName = window.location.pathname.split("/"); | |
var track = pathName.pop(); | |
return { | |
track: track, | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment