mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 12:55:13 +00:00
Fixed domnodeinserted listener and moved buttons
This commit is contained in:
@@ -46,4 +46,8 @@
|
||||
/*background: url('chrome-extension://__MSG_@@extension_id__/mute.png') !important;*/
|
||||
background-repeat: no-repeat;
|
||||
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}
|
||||
* @return {function(...[*]=)}
|
||||
*/
|
||||
function addControls(chatBody) {
|
||||
return function (event) {
|
||||
console.log(event);
|
||||
if (event.target.className === 'im-mess--check fl_l') {
|
||||
const message = event.target.parentElement;
|
||||
addControlButton(message)
|
||||
}
|
||||
function addControls(event) {
|
||||
console.log(event);
|
||||
if (event.target.className === 'im-mess--check fl_l') {
|
||||
const message = event.target.parentElement;
|
||||
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) {
|
||||
if (event.target.className === 'im-mess-stack _im_mess_stack ') {
|
||||
let idToHide;
|
||||
chrome.storage.sync.get('idToHide', function(data) {
|
||||
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.
|
||||
var hideInterval = setInterval(function () {
|
||||
var chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
||||
for (var item of chatBody.children) {
|
||||
if (item.dataset.peer === idToHide) {
|
||||
if (item.style.display !== "none") {
|
||||
item.style.display = "none";
|
||||
} else {
|
||||
clearInterval(hideInterval);
|
||||
}
|
||||
}
|
||||
const chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
||||
if (hideElements(chatBody)) {
|
||||
clearInterval(hideInterval);
|
||||
}
|
||||
}, 200);
|
||||
|
||||
Reference in New Issue
Block a user