mirror of
https://codeberg.org/vlw/stadia-avatar.git
synced 2025-09-13 23:23:40 +02:00
Bot userscript draft and folder structure
This commit is contained in:
parent
30fb63360c
commit
51a70545b0
5 changed files with 72 additions and 0 deletions
0
endpoint/get.php
Normal file
0
endpoint/get.php
Normal file
0
setup-db.sql
Normal file
0
setup-db.sql
Normal file
29
userscript-bot/bot.js
Normal file
29
userscript-bot/bot.js
Normal 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.");
|
||||
}
|
||||
})();
|
11
userscript-client/UserScript.js
Normal file
11
userscript-client/UserScript.js
Normal 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==
|
32
userscript-client/script.js
Normal file
32
userscript-client/script.js
Normal 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();
|
||||
})();
|
Loading…
Add table
Reference in a new issue