-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #256 from csfloat/feature/profile-comment-warning
Shows Warning if Creating a Profile Comment with Trigger Words
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`<div class="container"> | ||
<b>WARNING:</b> Commenting on profiles with words relating to buying and selling CS2 items | ||
<b>WILL</b> result in a Steam community ban! | ||
</div>`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {init} from './utils'; | ||
import '../components/profile/comment_warning'; | ||
|
||
init('src/lib/page_scripts/profile.js', main); | ||
|
||
async function main() {} |