meow
This commit is contained in:
89
webkit/index.tsx
Normal file
89
webkit/index.tsx
Normal file
@@ -0,0 +1,89 @@
|
||||
type Millennium = {
|
||||
callServerMethod: (methodName: string, kwargs?: any) => Promise<any>;
|
||||
findElement: (privateDocument: Document, querySelector: string, timeOut?: number) => Promise<NodeListOf<Element>>;
|
||||
};
|
||||
|
||||
declare const Millennium: Millennium;
|
||||
|
||||
export default async function WebkitMain() {
|
||||
try {
|
||||
|
||||
if (typeof Millennium === 'undefined') {
|
||||
console.error('csst.at probably down idk...');
|
||||
return;
|
||||
}
|
||||
|
||||
const styles = `
|
||||
.rip-btn {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
height: 3rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 20px;
|
||||
color: #FFF;
|
||||
font-weight: 800;
|
||||
transition: all 0.5s cubic-bezier(.23, 1, .32, 1);
|
||||
background-color: #2d243aff;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
border: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.rip-btn:hover {
|
||||
background-color: #FFF;
|
||||
color: #2d243aff;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
}`;
|
||||
|
||||
const styleSheet = document.createElement('style');
|
||||
styleSheet.innerText = styles;
|
||||
document.head.appendChild(styleSheet);
|
||||
|
||||
const rightCol = await Millennium.findElement(document, '.profile_rightcol');
|
||||
|
||||
if (rightCol.length > 0) {
|
||||
const parser = new DOMParser();
|
||||
const profileUrl = `${window.location.href}/?xml=1`;
|
||||
|
||||
const profileResponse = await fetch(profileUrl);
|
||||
if (!profileResponse.ok) {
|
||||
console.error(`Leetify: Failed to fetch profile data: ${profileResponse.status} ${profileResponse.statusText}`);
|
||||
return;
|
||||
}
|
||||
|
||||
const profileXmlText = await profileResponse.text();
|
||||
const profileXmlDoc = parser.parseFromString(profileXmlText, 'application/xml');
|
||||
|
||||
const steamID64 = profileXmlDoc.querySelector('steamID64')?.textContent || '0';
|
||||
|
||||
if (!steamID64 || steamID64 === '0') {
|
||||
console.error('Leetify: Could not parse steamID64 from URL.');
|
||||
return;
|
||||
}
|
||||
|
||||
const statsContainer = document.createElement('div');
|
||||
statsContainer.className = 'account-row';
|
||||
|
||||
const button = document.createElement('div');
|
||||
button.className = 'rip-btn';
|
||||
|
||||
button.textContent = '.rip';
|
||||
button.onclick = () => {
|
||||
window.open(`https://steamcommunity.rip/id/${steamID64}`, '_self', 'noopener,noreferrer');
|
||||
};
|
||||
|
||||
statsContainer.appendChild(button);
|
||||
rightCol[0].insertBefore(statsContainer, rightCol[0].children[1]);
|
||||
} else {
|
||||
console.error('Leetify: Parent container ".profile_rightcol" not found');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Leetify: Error in WebkitMain:', error);
|
||||
console.error('Leetify: Stack trace:', error.stack);
|
||||
}
|
||||
}
|
||||
20
webkit/settings.tsx
Normal file
20
webkit/settings.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { BindPluginSettings } from '@steambrew/webkit';
|
||||
|
||||
type CheckBox = true | false;
|
||||
|
||||
type EnumerateInternal<N extends number, Acc extends number[] = []> = Acc['length'] extends N ? Acc[number] : EnumerateInternal<N, [...Acc, Acc['length']]>;
|
||||
|
||||
type Enumerate<Min extends number, Max extends number> = Exclude<EnumerateInternal<Max>, EnumerateInternal<Min>> | Max;
|
||||
|
||||
type NumberTextInput<Min extends number, Max extends number> = Min | Enumerate<Min, Max>;
|
||||
|
||||
type DropDown<T extends readonly any[]> = T[number];
|
||||
|
||||
interface SettingsProps {
|
||||
doFrontEndCall: CheckBox;
|
||||
overrideWebkitDocument: CheckBox;
|
||||
numberTextInput: NumberTextInput<1, 100>;
|
||||
frontEndMessage: DropDown<['hello', 'hi', 'hello again', false, 69]>;
|
||||
}
|
||||
|
||||
export let PluginSettings: SettingsProps = BindPluginSettings();
|
||||
9
webkit/tsconfig.json
Normal file
9
webkit/tsconfig.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["."],
|
||||
"exclude": ["node_modules", "../frontend"]
|
||||
}
|
||||
Reference in New Issue
Block a user