Bot userscript draft and folder structure

This commit is contained in:
Victor Westerlund 2021-02-04 03:36:31 +01:00
parent 30fb63360c
commit 51a70545b0
5 changed files with 72 additions and 0 deletions

0
endpoint/get.php Normal file
View file

0
setup-db.sql Normal file
View file

29
userscript-bot/bot.js Normal file
View file

@ -0,0 +1,29 @@
(function() {
'use strict';
const targetJSName = "FhFdCc";
let observer = null;
const receivedMessage = (mutations,observer) => {
const mutation = mutations[3].addedNodes[0];
console.log(mutations);
}
function attachObserver() {
const target = document.querySelector(`[jsname="${targetJSName}"]`);
observer = new MutationObserver(receivedMessage);
observer.observe(target,{
subtree: true,
childList: true,
attributes: true,
characterData: true
});
}
// Start the StadiaAvatar bot with 'window._StadiaAvatar()'
window._StadiaAvatar = () => {
attachObserver();
console.log("StadiaAvatar bot started.");
}
})();

View file

@ -0,0 +1,11 @@
// ==UserScript==
// @name Stadia Avatars
// @namespace https://victorwesterlund.com/
// @version 0.1
// @description try to take over the world!
// @author VictorWesterlund
// @match https://stadia.google.com/*
// @grant none
// @require file://C:\path\to\userscript.user.js
// @noframes
// ==/UserScript==

View file

@ -0,0 +1,32 @@
(function() {
'use strict';
function getElementByJSname(name) {
return document.querySelector(`[jsname="${name}"]`);
}
const myID = () => {
let element = getElementByJSname("HiaYvf");
return element.getAttribute("data-player-id");
}
function locationChanged() {
switch(window.location.pathname) {
case "/home": console.log("home"); break;
case "/settings": console.log("settings"); break;
default: break;
}
}
let currentLocation = window.location.href;
// Poll window.location.href for changes
let poll = setInterval(() => {
if(window.location.href != currentLocation) {
currentLocation = window.location.href;
locationChanged();
}
},500);
locationChanged();
})();