Перешел на domnodeinserted

This commit is contained in:
2020-04-13 21:10:34 +03:00
parent 26d9856f83
commit 55684be7f7
8 changed files with 71 additions and 8 deletions

49
controls.css Normal file
View File

@@ -0,0 +1,49 @@
.mute_message .mutetooltip {
visibility: hidden;
width: 120px;
background-color: #555;
color: #fff;
text-align: center;
padding: 5px 0;
border-radius: 6px;
/* Position the tooltip text */
position: absolute;
z-index: 1;
bottom: 125%;
left: 50%;
margin-left: -60px;
/* Fade in tooltip */
opacity: 0;
transition: opacity 0.3s;
}
/* Tooltip arrow */
.mute_message .mutetooltip::after {
content: "";
position: absolute;
top: 100%;
left: 50%;
margin-left: -5px;
border-width: 5px;
border-style: solid;
border-color: #555 transparent transparent transparent;
}
/* Show the tooltip text when you mouse over the tooltip container */
.mute_message:hover .mutetooltip {
visibility: visible;
opacity: 1;
}
.mute_message {
width: 16px;
height: 16px;
position: relative;
display: inline-block;
vertical-align: top;
background: url('chrome-extension://__MSG_@@extension_id__/mute.png') no-repeat top left;
background-repeat: no-repeat;
padding: 6px;
}

10
controls.js vendored
View File

@@ -1,11 +1,12 @@
var showMembersBtn = document.getElementsByClassName("_im_chat_members im-page--members")[0]; var showMembersBtn = document.getElementsByClassName("_im_chat_members im-page--members")[0];
var controlsArea; var controlsArea;
/*
function isInt(value) { function isInt(value) {
return !isNaN(value) && (function(x) { return (x | 0) === x; })(parseFloat(value)) return !isNaN(value) && (function(x) { return (x | 0) === x; })(parseFloat(value))
} }
/*
showMembersBtn.addEventListener('click', function() { showMembersBtn.addEventListener('click', function() {
var checkExist = setInterval(function() { var checkExist = setInterval(function() {
controlsArea = document.getElementsByClassName("ListItem__aside"); controlsArea = document.getElementsByClassName("ListItem__aside");
@@ -29,7 +30,11 @@ showMembersBtn.addEventListener('click', function() {
*/ */
function muteBtnHTML(id) { function muteBtnHTML(id) {
return '<span style="vertical-align:middle;" class="mute_message" id="mute' + id + '">🔇</span>' return `
<span class="mute_message" id="mute` + id + `">
🔇
<span class="mutetooltip">Заглушить</span>
</span>`
} }
function addControls() { function addControls() {
@@ -55,6 +60,7 @@ function addControls() {
var clicked_id = event.target.id.substr(event.target.id.length - 9); var clicked_id = event.target.id.substr(event.target.id.length - 9);
chrome.storage.sync.set({idToHide: clicked_id}, function() { chrome.storage.sync.set({idToHide: clicked_id}, function() {
hidePeer(clicked_id);
console.log('idToHide: ' + clicked_id); console.log('idToHide: ' + clicked_id);
}); });
}); });

View File

@@ -18,4 +18,10 @@ function hidePeer(peer) {
}); });
} }
var interval = window.setInterval(function(){ hidePeer(idToHide) }, 500); //var interval = window.setInterval(function(){ hidePeer(idToHide) }, 500);
var chatBody = document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
chatBody.addEventListener('DOMNodeInserted', function() {
hidePeer(idToHide);
});

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@@ -1,11 +1,12 @@
{ {
"name": "Hide Cringe", "name": "VK Mute",
"icons": { "icons": {
"128": "icon128.png", "140": "icons/icon140.png",
"48": "icon48.png" "128": "icons/icon128.png",
"48": "icons/icon48.png"
}, },
"version": "1.0", "version": "1.0",
"description": "Hides cringe", "description": "Позволяет заглушить нежелаемых собеседников",
"permissions": ["activeTab", "declarativeContent", "storage"], "permissions": ["activeTab", "declarativeContent", "storage"],
"background": { "background": {
"scripts": [ "scripts": [
@@ -24,7 +25,8 @@
}, },
{ {
"matches": ["https://*.vk.com/*"], "matches": ["https://*.vk.com/*"],
"js": ["controls.js"] "js": ["controls.js"],
"css": ["controls.css"]
} }
] ]
} }

BIN
mute.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB