mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 21:05:16 +00:00
Fixed domnodeinserted listener and moved buttons
This commit is contained in:
@@ -47,3 +47,7 @@
|
|||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.im-mess--actions {
|
||||||
|
margin-right: -30px !important;
|
||||||
|
}
|
||||||
12
controls.js
vendored
12
controls.js
vendored
@@ -19,13 +19,11 @@ function muteBtnHTML(id) {
|
|||||||
* @param chatBody {HTMLElement}
|
* @param chatBody {HTMLElement}
|
||||||
* @return {function(...[*]=)}
|
* @return {function(...[*]=)}
|
||||||
*/
|
*/
|
||||||
function addControls(chatBody) {
|
function addControls(event) {
|
||||||
return function (event) {
|
console.log(event);
|
||||||
console.log(event);
|
if (event.target.className === 'im-mess--check fl_l') {
|
||||||
if (event.target.className === 'im-mess--check fl_l') {
|
const message = event.target.parentElement;
|
||||||
const message = event.target.parentElement;
|
addControlButton(message)
|
||||||
addControlButton(message)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,27 @@
|
|||||||
var idToHide;
|
// Returns false if there was an element not hidden
|
||||||
|
function hideElements(chatBody) {
|
||||||
|
let idToHide;
|
||||||
|
chrome.storage.sync.get('idToHide', function(data) {
|
||||||
|
idToHide = data.idToHide;
|
||||||
|
});
|
||||||
|
|
||||||
var chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
let r = true;
|
||||||
|
for (var item of chatBody.children) {
|
||||||
|
if (item.dataset.peer === idToHide) {
|
||||||
|
if (item.style.display !== "none") {
|
||||||
|
item.style.display = "none";
|
||||||
|
r = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
let chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
||||||
|
|
||||||
chatBody.addEventListener('DOMNodeInserted', function(event) {
|
chatBody.addEventListener('DOMNodeInserted', function(event) {
|
||||||
if (event.target.className === 'im-mess-stack _im_mess_stack ') {
|
if (event.target.className === 'im-mess-stack _im_mess_stack ') {
|
||||||
|
let idToHide;
|
||||||
chrome.storage.sync.get('idToHide', function(data) {
|
chrome.storage.sync.get('idToHide', function(data) {
|
||||||
idToHide = data.idToHide;
|
idToHide = data.idToHide;
|
||||||
});
|
});
|
||||||
@@ -18,20 +36,10 @@ chatBody.addEventListener('DOMNodeInserted', function(event) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.storage.sync.get('idToHide', function(data) {
|
|
||||||
idToHide = data.idToHide;
|
|
||||||
});
|
|
||||||
|
|
||||||
// Try to hide until successful. Needed for page refresh.
|
// Try to hide until successful. Needed for page refresh.
|
||||||
var hideInterval = setInterval(function () {
|
var hideInterval = setInterval(function () {
|
||||||
var chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
const chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
||||||
for (var item of chatBody.children) {
|
if (hideElements(chatBody)) {
|
||||||
if (item.dataset.peer === idToHide) {
|
clearInterval(hideInterval);
|
||||||
if (item.style.display !== "none") {
|
|
||||||
item.style.display = "none";
|
|
||||||
} else {
|
|
||||||
clearInterval(hideInterval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|||||||
Reference in New Issue
Block a user