mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 12:55:13 +00:00
Возвращение сообщений без перезагрузки
This commit is contained in:
81
extension/dist/dom.js
vendored
81
extension/dist/dom.js
vendored
File diff suppressed because one or more lines are too long
@@ -6,7 +6,7 @@
|
|||||||
"128": "assets/icons/icon128.png",
|
"128": "assets/icons/icon128.png",
|
||||||
"48": "assets/icons/icon48.png"
|
"48": "assets/icons/icon48.png"
|
||||||
},
|
},
|
||||||
"version": "1.0",
|
"version": "1.2",
|
||||||
"description": "Позволяет заглушить нежелаемых собеседников",
|
"description": "Позволяет заглушить нежелаемых собеседников",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab",
|
"activeTab",
|
||||||
|
|||||||
859
package-lock.json
generated
859
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@
|
|||||||
"css-loader": "^3.5.2",
|
"css-loader": "^3.5.2",
|
||||||
"html-webpack-plugin": "^4.2.0",
|
"html-webpack-plugin": "^4.2.0",
|
||||||
"style-loader": "^1.1.4",
|
"style-loader": "^1.1.4",
|
||||||
"webpack": "^4.42.1"
|
"webpack": "^4.42.1",
|
||||||
|
"webpack-cli": "^4.7.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
6
src/dom/controls.js
vendored
6
src/dom/controls.js
vendored
@@ -66,7 +66,11 @@ function setIdToHideHandle() {
|
|||||||
name: clickedName
|
name: clickedName
|
||||||
});
|
});
|
||||||
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
||||||
hideExistingMessages();
|
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||||
|
if (data.isExtensionOn) {
|
||||||
|
hideExistingMessages();
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {getChatBody} from "../utils/getChatBody";
|
import {getChatBody} from "../utils/getChatBody";
|
||||||
import {tryToAddControls} from "./controls";
|
import {tryToAddControls, hideExistingMessages} from "./controls";
|
||||||
|
|
||||||
export function addNewMessageEventListener() {
|
export function addNewMessageEventListener() {
|
||||||
const chatBody = getChatBody();
|
const chatBody = getChatBody();
|
||||||
@@ -22,3 +22,37 @@ function newMessageHandler(message) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function returnMessagesEventListener() {
|
||||||
|
chrome.storage.onChanged.addListener(function(changes) {
|
||||||
|
const isExtensionOn = changes.isExtensionOn;
|
||||||
|
const idsToHide = changes.idsToHide;
|
||||||
|
const chatBody = getChatBody();
|
||||||
|
if (isExtensionOn) {
|
||||||
|
if (isExtensionOn.newValue === false) {
|
||||||
|
for (let item of chatBody.children) {
|
||||||
|
item.style.display = "block";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
hideExistingMessages();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (idsToHide) {
|
||||||
|
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||||
|
if (data.isExtensionOn) {
|
||||||
|
if (idsToHide.newValue.length < idsToHide.oldValue.length) {
|
||||||
|
// for (let item of chatBody.children) {
|
||||||
|
// item.style.display = "block";
|
||||||
|
// }
|
||||||
|
// hideExistingMessages();
|
||||||
|
for (let item of chatBody.children) {
|
||||||
|
if (idsToHide.newValue.filter(user => user.id == item.dataset.peer).length === 0) {
|
||||||
|
item.style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import './dom.css'
|
import './dom.css'
|
||||||
import {createTryToInitInterval, hideExistingMessages, tryToInitControls} from "./controls";
|
import {createTryToInitInterval, hideExistingMessages, tryToInitControls} from "./controls";
|
||||||
import {UrlController} from "../utils/Url";
|
import {UrlController} from "../utils/Url";
|
||||||
import {addNewMessageEventListener} from "./hide_element";
|
import {addNewMessageEventListener, returnMessagesEventListener} from "./hide_element";
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
const url = new UrlController();
|
const url = new UrlController();
|
||||||
@@ -9,6 +9,7 @@ function init() {
|
|||||||
if (tryToInitControls()) {
|
if (tryToInitControls()) {
|
||||||
createTryToInitInterval();
|
createTryToInitInterval();
|
||||||
addNewMessageEventListener();
|
addNewMessageEventListener();
|
||||||
|
returnMessagesEventListener();
|
||||||
hideExistingMessages();
|
hideExistingMessages();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user