mirror of https://github.com/Alia5/GlosSI
Add/Start SteamTweaks TS/JS package
parent
766cac3969
commit
d60def51d5
@ -0,0 +1,187 @@
|
|||||||
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
'eslint:recommended',
|
||||||
|
'plugin:@typescript-eslint/eslint-recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended',
|
||||||
|
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
||||||
|
],
|
||||||
|
env: {
|
||||||
|
browser: true,
|
||||||
|
node: false
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
'@typescript-eslint',
|
||||||
|
'no-null',
|
||||||
|
'prefer-arrow',
|
||||||
|
'import',
|
||||||
|
],
|
||||||
|
parser: '@typescript-eslint/parser', // Specifies the ESLint parser
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2022, // Allows for the parsing of modern ECMAScript features
|
||||||
|
sourceType: 'module',
|
||||||
|
ecmaFeatures: {
|
||||||
|
jsx: false,
|
||||||
|
},
|
||||||
|
project: ['./tsconfig.json'],
|
||||||
|
tsconfigRootDir: __dirname
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-namespace': 'off',
|
||||||
|
'@typescript-eslint/ban-types': 'error',
|
||||||
|
'@typescript-eslint/adjacent-overload-signatures': 'error',
|
||||||
|
'@typescript-eslint/array-type': 'error',
|
||||||
|
'@typescript-eslint/consistent-type-definitions': ['error', 'interface'],
|
||||||
|
'@typescript-eslint/no-inferrable-types': 'error',
|
||||||
|
'@typescript-eslint/no-misused-new': 'error',
|
||||||
|
'@typescript-eslint/no-this-alias': 'error',
|
||||||
|
'@typescript-eslint/prefer-for-of': 'error',
|
||||||
|
'@typescript-eslint/prefer-function-type': 'error',
|
||||||
|
'@typescript-eslint/prefer-namespace-keyword': 'error',
|
||||||
|
'no-inner-declarations': 'off', // we have es6blocked scoped functions.
|
||||||
|
'@typescript-eslint/triple-slash-reference': 'error',
|
||||||
|
'@typescript-eslint/type-annotation-spacing': 'error',
|
||||||
|
'@typescript-eslint/unified-signatures': 'error',
|
||||||
|
'@typescript-eslint/no-explicit-any': 'error',
|
||||||
|
'@typescript-eslint/no-unused-vars': 'error',
|
||||||
|
'@typescript-eslint/unbound-method': 'warn',
|
||||||
|
'@typescript-eslint/semi': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'@typescript-eslint/quotes': [
|
||||||
|
'warn',
|
||||||
|
'single'
|
||||||
|
],
|
||||||
|
'@typescript-eslint/member-delimiter-style': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'multiline': {
|
||||||
|
'delimiter': 'semi',
|
||||||
|
'requireLast': true
|
||||||
|
},
|
||||||
|
'singleline': {
|
||||||
|
'delimiter': 'semi',
|
||||||
|
'requireLast': false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@typescript-eslint/indent': [
|
||||||
|
'warn',
|
||||||
|
4,
|
||||||
|
{
|
||||||
|
'FunctionDeclaration': {
|
||||||
|
'parameters': 'first'
|
||||||
|
},
|
||||||
|
'FunctionExpression': {
|
||||||
|
'parameters': 'first'
|
||||||
|
},
|
||||||
|
'SwitchCase': 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
'@typescript-eslint/explicit-member-accessibility': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'accessibility': 'explicit'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'@typescript-eslint/no-use-before-define': ['error', { 'functions': false }],
|
||||||
|
"@typescript-eslint/naming-convention": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"selector": "default",
|
||||||
|
"format": ["camelCase", "PascalCase"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": "variable",
|
||||||
|
"format": ["camelCase", "UPPER_CASE"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": "parameter",
|
||||||
|
"format": ["camelCase"],
|
||||||
|
"leadingUnderscore": "allow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": "memberLike",
|
||||||
|
"modifiers": ["private"],
|
||||||
|
"format": ["camelCase"],
|
||||||
|
"leadingUnderscore": "require"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"selector": "typeLike",
|
||||||
|
"format": ["PascalCase"]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-return-await': 'error',
|
||||||
|
'arrow-body-style': 'error',
|
||||||
|
'arrow-parens': [
|
||||||
|
'error',
|
||||||
|
'always'
|
||||||
|
],
|
||||||
|
'camelcase': ['warn', { "ignoreImports": true }],
|
||||||
|
'comma-dangle': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'objects': 'never',
|
||||||
|
'arrays': 'never',
|
||||||
|
'functions': 'never'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'prefer-arrow/prefer-arrow-functions': 'error',
|
||||||
|
'prefer-arrow-callback': 'error',
|
||||||
|
'prefer-const': 'error',
|
||||||
|
'quote-props': [
|
||||||
|
'error',
|
||||||
|
'consistent-as-needed'
|
||||||
|
],
|
||||||
|
'no-var': 'error',
|
||||||
|
'new-parens': 'error',
|
||||||
|
'no-caller': 'error',
|
||||||
|
'no-cond-assign': 'error',
|
||||||
|
'no-debugger': 'error',
|
||||||
|
'no-empty': 'error',
|
||||||
|
'no-eval': 'error',
|
||||||
|
'no-multiple-empty-lines': 'warn',
|
||||||
|
'no-new-wrappers': 'error',
|
||||||
|
'no-redeclare': 'error',
|
||||||
|
'no-shadow': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'hoist': 'all'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'no-null/no-null': 'error',
|
||||||
|
'no-throw-literal': 'error',
|
||||||
|
'no-trailing-spaces': 'error',
|
||||||
|
'no-undef-init': 'error',
|
||||||
|
'no-underscore-dangle': 'error',
|
||||||
|
'no-unsafe-finally': 'error',
|
||||||
|
'no-unused-labels': 'error',
|
||||||
|
'spaced-comment': 'error',
|
||||||
|
'use-isnan': 'error',
|
||||||
|
'max-lines': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
'max': 300,
|
||||||
|
'skipBlankLines': true,
|
||||||
|
'skipComments': true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'max-len': [
|
||||||
|
'warn',
|
||||||
|
{
|
||||||
|
'code': 140
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'dot-notation': 'error',
|
||||||
|
'eqeqeq': 'error',
|
||||||
|
'eol-last': 'error',
|
||||||
|
'linebreak-style': ['error', 'windows'],
|
||||||
|
'block-spacing': ['error', 'always'],
|
||||||
|
'object-curly-spacing': ["error", "always"],
|
||||||
|
'import/no-deprecated': 'warn', // eslint deprecation rule sucks. just wrns on deprecated IMPORTs
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
},
|
||||||
|
};
|
@ -0,0 +1 @@
|
|||||||
|
19
|
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Attach to Steam CEF",
|
||||||
|
"port": 8080,
|
||||||
|
"request": "attach",
|
||||||
|
"type": "chrome",
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "glossi_steamtweaks",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {},
|
||||||
|
"author": "Peter Repukat - FlatspotSoftware",
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"@rollup/plugin-typescript": "^11.0.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.49.0",
|
||||||
|
"@typescript-eslint/parser": "^5.49.0",
|
||||||
|
"eslint": "^8.33.0",
|
||||||
|
"eslint-plugin-import": "^2.27.5",
|
||||||
|
"eslint-plugin-no-null": "^1.0.2",
|
||||||
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
||||||
|
"rollup": "^3.12.0",
|
||||||
|
"typescript": "^4.9.4"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
import typescript from '@rollup/plugin-typescript';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
input: 'src/Tweaks/Overlay/HideFPSCounter.ts',
|
||||||
|
output: {
|
||||||
|
file: 'dist/glossiTweaks.js',
|
||||||
|
sourcemap: "inline",
|
||||||
|
format: 'es',
|
||||||
|
},
|
||||||
|
plugins: [typescript()]
|
||||||
|
};
|
@ -0,0 +1,14 @@
|
|||||||
|
export interface SteamClient {
|
||||||
|
Settings: {
|
||||||
|
SetInGameOverlayShowFPSCorner: (value: 0|1|2|3|4) => void;
|
||||||
|
SetInGameOverlayShowFPSContrast: (value: boolean) => void;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
SteamClient: SteamClient;
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line
|
||||||
|
declare const SteamClient: SteamClient;
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
import type { SteamConfig } from "../../common/util/types";
|
||||||
|
import { initTweak } from "../../common/tweakApi";
|
||||||
|
|
||||||
|
// variables here are scoped to the tweak
|
||||||
|
// and are not accessible from other tweaks or even the main script
|
||||||
|
// there is no risk of conflicts
|
||||||
|
|
||||||
|
|
||||||
|
const originalFpsCorner = Number(
|
||||||
|
((await GlosSI.getSettings()).system as SteamConfig)
|
||||||
|
.InGameOverlayShowFPSCorner
|
||||||
|
) as 0 | 1 | 2 | 3 | 4;
|
||||||
|
|
||||||
|
initTweak('HideFPSCounter', {
|
||||||
|
install: () => {
|
||||||
|
SteamClient.Settings.SetInGameOverlayShowFPSCorner(0);
|
||||||
|
},
|
||||||
|
uninstall: () => {
|
||||||
|
SteamClient.Settings.SetInGameOverlayShowFPSCorner(originalFpsCorner);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,62 @@
|
|||||||
|
import type { SteamConfig } from './util/types';
|
||||||
|
class GlosSIApi {
|
||||||
|
public getSettings(): Promise<SteamConfig> {
|
||||||
|
return fetch('http://localhost:8756/steam_settings')
|
||||||
|
.then(
|
||||||
|
(res) => res.json().then(
|
||||||
|
(json) => (json as SteamConfig).UserLocalConfigStore as SteamConfig
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
GlosSITweaks: Record<string, {install: () => unknown; uninstall?: () => void}>;
|
||||||
|
GlosSI: InstanceType<typeof GlosSIApi>;
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line
|
||||||
|
const GlosSI: InstanceType<typeof GlosSIApi>;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const installGlosSIApi = () => {
|
||||||
|
window.GlosSITweaks = {
|
||||||
|
GlosSI: {
|
||||||
|
install: () => {
|
||||||
|
const api = new GlosSIApi();
|
||||||
|
Object.assign(window, { GlosSI: api });
|
||||||
|
},
|
||||||
|
uninstall: () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
delete window.GlosSI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.GlosSITweaks.GlosSI.install();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!window.GlosSITweaks || !window.GlosSI) {
|
||||||
|
installGlosSIApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initTweak = <T>(name: string, tweakMain: (() => T)|{
|
||||||
|
install: () => T;
|
||||||
|
uninstall: () => void;
|
||||||
|
}, force = false): T|Error => {
|
||||||
|
if (!force && window.GlosSITweaks[name]) {
|
||||||
|
return new Error(`Tweak ${name} is already installed!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof tweakMain === 'object') {
|
||||||
|
window.GlosSITweaks[name] = { install: tweakMain.install, uninstall: () => {
|
||||||
|
tweakMain.uninstall();
|
||||||
|
delete window.GlosSITweaks[name];
|
||||||
|
} };
|
||||||
|
} else {
|
||||||
|
window.GlosSITweaks[name] = { install: tweakMain };
|
||||||
|
}
|
||||||
|
return window.GlosSITweaks[name].install() as T;
|
||||||
|
|
||||||
|
};
|
@ -0,0 +1,3 @@
|
|||||||
|
export interface SteamConfig {
|
||||||
|
[key: string]: string|SteamConfig;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ES2022",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"inlineSourceMap": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"strict": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"useDefineForClassFields": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"lib": [
|
||||||
|
"esnext",
|
||||||
|
"DOM"
|
||||||
|
],
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"src/**/*"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"node_modules"
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue