Redirect Google Classroom to correct user Account
当前为
// ==UserScript==
// @name Google Classroom User Account Redirect
// @description Redirect Google Classroom to correct user Account
// @version 0.1
// @author Torkelicous
// @icon https://www.gstatic.com/classroom/logo_square_rounded.svg
// @include https://classroom.google.com/*
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// @license MIT
// @namespace https://greasyfork.org/users/1403155
// ==/UserScript==
(function() {
// GUI for configuring wantedAccount
function createGUI() {
const guiContainer = document.createElement('div');
guiContainer.style.position = 'fixed';
guiContainer.style.top = '10px';
guiContainer.style.right = '200px';
guiContainer.style.padding = '10px';
guiContainer.style.backgroundColor = 'white';
guiContainer.style.border = '1px solid black';
guiContainer.style.zIndex = '1000';
const label = document.createElement('label');
label.textContent = 'Account Number: ';
guiContainer.appendChild(label);
const input = document.createElement('input');
input.type = 'number';
input.value = GM_getValue('wantedAccount', 2);
guiContainer.appendChild(input);
const button = document.createElement('button');
button.textContent = 'Save';
button.onclick = function() {
GM_setValue('wantedAccount', input.value);
location.reload();
};
guiContainer.appendChild(button);
document.body.appendChild(guiContainer);
}
window.addEventListener('load', createGUI);
let wantedAccount = GM_getValue('wantedAccount', 1);
var path0 = window.location.pathname;
var path1 = path0.substring(0, 5);
if (path1 != `/u/${wantedAccount}/`)
{
window.location.replace(`https://classroom.google.com/u/${wantedAccount}/`);
}
})();