diff --git a/manifest.json b/manifest.json index 1b57304d..524cf233 100644 --- a/manifest.json +++ b/manifest.json @@ -37,6 +37,11 @@ "matches": ["*://*.steamcommunity.com/*/tradeoffers/*"], "js": ["src/lib/page_scripts/trade_offers.js"], "css": ["src/global.css"] + }, + { + "matches": ["*://*.steamcommunity.com/id/*", "*://*.steamcommunity.com/profiles/*"], + "js": ["src/lib/page_scripts/profile.js"], + "css": ["src/global.css"] } ], "background": { diff --git a/src/lib/components/profile/comment_warning.ts b/src/lib/components/profile/comment_warning.ts new file mode 100644 index 00000000..64741a77 --- /dev/null +++ b/src/lib/components/profile/comment_warning.ts @@ -0,0 +1,70 @@ +import {css, html} from 'lit'; + +import {CustomElement, InjectAfter, InjectionMode} from '../injectors'; +import {FloatElement} from '../custom'; +import '../common/ui/steam-button'; +import {state} from 'lit/decorators.js'; +import {Observe} from '../../utils/observers'; + +@CustomElement() +@InjectAfter('.commentthread_area .commentthread_header', InjectionMode.ONCE) +export class CommentWarning extends FloatElement { + @state() + show = false; + + static styles = [ + ...FloatElement.styles, + css` + .container { + background-color: rgba(235, 87, 87, 0.05); + color: #de6667; + border-radius: 6px; + padding: 8px; + margin: 5px; + font-size: 14px; + } + `, + ]; + + private getRawCommentBoxText(): string { + const elems = document.getElementsByClassName('commentthread_textarea'); + if (elems.length === 0) { + return ''; + } + + const elem = elems[0] as HTMLTextAreaElement; + return elem.value || ''; + } + + async connectedCallback() { + super.connectedCallback(); + + Observe( + () => { + return this.getRawCommentBoxText(); + }, + () => { + this.refreshWarningApplicable(); + } + ); + } + + refreshWarningApplicable() { + const text = this.getRawCommentBoxText(); + const words = new Set(text.toLowerCase().split(' ')); + + const hasTriggerWord = ['buy', 'sell', 'bought', 'sold', 'csfloat'].some((e) => words.has(e)); + this.show = hasTriggerWord; + } + + render() { + if (!this.show) { + return html``; + } + + return html`
+ WARNING: Commenting on profiles with words relating to buying and selling CS2 items + WILL result in a Steam community ban! +
`; + } +} diff --git a/src/lib/page_scripts/profile.ts b/src/lib/page_scripts/profile.ts new file mode 100644 index 00000000..3f2b8271 --- /dev/null +++ b/src/lib/page_scripts/profile.ts @@ -0,0 +1,6 @@ +import {init} from './utils'; +import '../components/profile/comment_warning'; + +init('src/lib/page_scripts/profile.js', main); + +async function main() {}