mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 04:45:15 +00:00
Возвращение сообщений без перезагрузки
This commit is contained in:
79
extension/dist/dom.js
vendored
79
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",
|
||||
"48": "assets/icons/icon48.png"
|
||||
},
|
||||
"version": "1.0",
|
||||
"version": "1.2",
|
||||
"description": "Позволяет заглушить нежелаемых собеседников",
|
||||
"permissions": [
|
||||
"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",
|
||||
"html-webpack-plugin": "^4.2.0",
|
||||
"style-loader": "^1.1.4",
|
||||
"webpack": "^4.42.1"
|
||||
"webpack": "^4.42.1",
|
||||
"webpack-cli": "^4.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
4
src/dom/controls.js
vendored
4
src/dom/controls.js
vendored
@@ -66,7 +66,11 @@ function setIdToHideHandle() {
|
||||
name: clickedName
|
||||
});
|
||||
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
||||
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||
if (data.isExtensionOn) {
|
||||
hideExistingMessages();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {getChatBody} from "../utils/getChatBody";
|
||||
import {tryToAddControls} from "./controls";
|
||||
import {tryToAddControls, hideExistingMessages} from "./controls";
|
||||
|
||||
export function addNewMessageEventListener() {
|
||||
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 {createTryToInitInterval, hideExistingMessages, tryToInitControls} from "./controls";
|
||||
import {UrlController} from "../utils/Url";
|
||||
import {addNewMessageEventListener} from "./hide_element";
|
||||
import {addNewMessageEventListener, returnMessagesEventListener} from "./hide_element";
|
||||
|
||||
function init() {
|
||||
const url = new UrlController();
|
||||
@@ -9,6 +9,7 @@ function init() {
|
||||
if (tryToInitControls()) {
|
||||
createTryToInitInterval();
|
||||
addNewMessageEventListener();
|
||||
returnMessagesEventListener();
|
||||
hideExistingMessages();
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user