Created
May 28, 2021 11:44
-
-
Save orestesgaolin/47620c3dde4c17e4d5e3b2752f59eb03 to your computer and use it in GitHub Desktop.
Userscript to switch Google Meet user on visiting the Meet call
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
// ==UserScript== | |
// @name Switch Google Meet user on visiting the page | |
// @namespace http://roszkowski.dev/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author Dominik Roszkowski | |
// @match *://meet.google.com/* | |
// @icon https://www.google.com/s2/favicons?domain=google.com | |
// @grant none | |
// ==/UserScript== | |
console.log("Hello, Let's see if we have to switch the user!"); | |
// Set this to your desired Google user id | |
var authUser = 1; | |
var current_location = window.document.location.toString(); | |
var loweredUrl = current_location.toLowerCase(); | |
console.log("Lowered URL: " + loweredUrl); | |
var authUserExists = loweredUrl.indexOf('authuser') >= 0; | |
var authUserIsSame = loweredUrl.indexOf('authuser=' + authUser) >= 0; | |
console.log("authUserExists: " + authUserExists); | |
console.log("authUserIsSame: " + authUserIsSame); | |
var shouldRedirect = ( !authUserExists || (!authUserIsSame) ) && parseInt(authUser) > 0; | |
console.log("shouldRedirect: " + shouldRedirect); | |
var isRedirectUriCorrect = ( /meet.google.com\/.*-.*-.*/.test(loweredUrl) || loweredUrl === 'https://meet.google.com/' || 'https://meet.google.com/landing' || 'https://meet.google.com/new' ); | |
console.log("isRedirectUriCorrect: " + isRedirectUriCorrect); | |
if ( shouldRedirect && isRedirectUriCorrect ) { | |
var _redirectUrl = loweredUrl; | |
var params = new URLSearchParams(_redirectUrl.split('?')[1]); | |
for (var pair of params.entries()) { | |
if( pair[0].toLowerCase() === "authuser" ) { | |
params.delete(pair[0]); | |
} | |
} | |
params.set('authuser', authUser); | |
_redirectUrl = _redirectUrl.split('?')[0] + "?" + params.toString(); | |
console.log("Redirecting to : " + _redirectUrl); | |
window.location.replace(_redirectUrl); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment