mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 12:55:13 +00:00
Add eslint
This commit is contained in:
@@ -1,46 +1,42 @@
|
||||
const INTERVAL_TIME = 100;
|
||||
const INTERVAL_TIME = 100
|
||||
|
||||
export class UrlController {
|
||||
constructor() {
|
||||
this._changeListeners = []
|
||||
this._interval = null
|
||||
this._url = window.location.href
|
||||
}
|
||||
|
||||
constructor() {
|
||||
this._changeListeners = [];
|
||||
this._interval = null;
|
||||
this._url = window.location.href;
|
||||
onChange(cb) {
|
||||
this._changeListeners.push(cb)
|
||||
if (this._interval === null)
|
||||
this._createInterval()
|
||||
}
|
||||
|
||||
removeEventListener(cb) {
|
||||
this._changeListeners = this._changeListeners.filter(item => item !== cb)
|
||||
if (this._changeListeners.length === 0)
|
||||
this._clearInterval()
|
||||
}
|
||||
|
||||
_intervalTick() {
|
||||
const currentUrl = window.location.href
|
||||
if (currentUrl !== this.url) {
|
||||
this._broadcast(this.url, currentUrl)
|
||||
this.url = currentUrl
|
||||
}
|
||||
}
|
||||
|
||||
onChange(cb) {
|
||||
this._changeListeners.push(cb);
|
||||
if (this._interval === null) {
|
||||
this._createInterval();
|
||||
}
|
||||
}
|
||||
_broadcast(oldUrl, newUrl) {
|
||||
this._changeListeners.forEach(cb => cb(oldUrl, newUrl))
|
||||
}
|
||||
|
||||
removeEventListener(cb) {
|
||||
this._changeListeners = this._changeListeners.filter(item=>item !== cb);
|
||||
if(this._changeListeners.length === 0) {
|
||||
this._clearInterval();
|
||||
}
|
||||
}
|
||||
_createInterval() {
|
||||
this.interval = setInterval(() => this._intervalTick(), INTERVAL_TIME)
|
||||
}
|
||||
|
||||
_intervalTick() {
|
||||
const currentUrl = window.location.href;
|
||||
if (currentUrl !== this.url) {
|
||||
this._broadcast(this.url, currentUrl);
|
||||
this.url = currentUrl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_broadcast(oldUrl, newUrl) {
|
||||
this._changeListeners.forEach(cb => cb(oldUrl, newUrl));
|
||||
}
|
||||
|
||||
_createInterval() {
|
||||
this.interval = setInterval(() => this._intervalTick(), INTERVAL_TIME)
|
||||
}
|
||||
|
||||
_clearInterval() {
|
||||
clearInterval(this.interval)
|
||||
this.interval = null
|
||||
}
|
||||
_clearInterval() {
|
||||
clearInterval(this.interval)
|
||||
this.interval = null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export function getChatBody() {
|
||||
return document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
||||
return document.getElementsByClassName('_im_peer_history im-page-chat-contain')[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user