Last active
August 21, 2022 04:48
-
-
Save Friss/e09abed8fe8b164268cb2ea89afaf68e to your computer and use it in GitHub Desktop.
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
javascript:(()=>{let e=0;const o=()=>{let o=Math.random()<=.25?"driver":"spectator",l=document.querySelectorAll(".cameras-column button:first-child"),t=document.querySelectorAll(".cameras-column button:last-child");console.log(e,o),"spectator"===o?l[e]?.click():t[e]?.click(),e++,e>=l.length&&(e=0)};document.querySelector('[overlay="controlPanel.overlays.ingameOverlay"] button:not(.visible)')?.click(),document.querySelector('[overlay="controlPanel.overlays.sessionInfo"] button:not(.visible)')?.click(),document.querySelector('[value="manufacturerLogo"]')?.click(),document.querySelector('[value="gapToLeader"]')?.click(),document.querySelector('[overlay="controlPanel.overlays.standingsTicker"] button:not(.visible)')?.click(),document.querySelector('[ng-model="controlPanel.overlays.driverInfo.settings.showCarData"].ng-empty')?.click(),document.querySelector('[value="driverAndDescription"]')?.click(),document.querySelector('[overlay="controlPanel.overlays.driverInfo"] button:not(.visible)')?.click(),o(),setInterval(o,6e4)})(); |
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
(() => { | |
const enableCorrectSettings = () => { | |
// Enable ingame overlay if not already | |
document | |
.querySelector( | |
'[overlay="controlPanel.overlays.ingameOverlay"] button:not(.visible)' | |
) | |
?.click(); | |
// Enable timing overlay if not already | |
document | |
.querySelector( | |
'[overlay="controlPanel.overlays.sessionInfo"] button:not(.visible)' | |
) | |
?.click(); | |
// Enable Manufactor logo | |
document.querySelector('[value="manufacturerLogo"]')?.click(); | |
// Enable gap to leader | |
document.querySelector('[value="gapToLeader"]')?.click(); | |
// Enable standings ticker | |
document | |
.querySelector( | |
'[overlay="controlPanel.overlays.standingsTicker"] button:not(.visible)' | |
) | |
?.click(); | |
// Enable car data | |
document | |
.querySelector( | |
'[ng-model="controlPanel.overlays.driverInfo.settings.showCarData"].ng-empty' | |
) | |
?.click(); | |
// Enable driver description | |
document.querySelector('[value="driverAndDescription"]')?.click(); | |
// Enable driver overlay | |
document | |
.querySelector( | |
'[overlay="controlPanel.overlays.driverInfo"] button:not(.visible)' | |
) | |
?.click(); | |
}; | |
// Start swapping cameras around | |
let currentCameraPlace = 0; | |
const swapCameras = () => { | |
let cameraChoice = Math.random() <= 0.25 ? 'driver' : 'spectator'; | |
let spectatorButtons = document.querySelectorAll( | |
'.cameras-column button:first-child' | |
); | |
let onboardButtons = document.querySelectorAll( | |
'.cameras-column button:last-child' | |
); | |
console.log(currentCameraPlace, cameraChoice); | |
if (cameraChoice === 'spectator') { | |
spectatorButtons[currentCameraPlace]?.click(); | |
} else { | |
onboardButtons[currentCameraPlace]?.click(); | |
} | |
currentCameraPlace++; | |
if (currentCameraPlace >= spectatorButtons.length) { | |
currentCameraPlace = 0; | |
} | |
}; | |
// Enable correct settings and start swapping cameras | |
enableCorrectSettings(); | |
swapCameras(); | |
setInterval(swapCameras, 1000 * 60); | |
})(); |
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
Right click bookmark bar => Bookmark Manager => Copy paste bookmarket.js as URL | |
https://try.terser.org/ for minifying | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment