mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 12:55:13 +00:00
Compare commits
35 Commits
v1.1
...
4089f640ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4089f640ea | ||
|
|
85596a95a6 | ||
|
|
4cebd66a85 | ||
|
|
bc49282b62 | ||
|
|
78c6b02214 | ||
|
|
97a8920057 | ||
|
|
a22c3485fa | ||
|
|
fd8c01e41b | ||
|
|
aad1365953 | ||
|
|
de578fd210 | ||
|
|
59ca6bb360 | ||
|
|
f7474d863b | ||
|
|
9a2381690e | ||
|
|
ecc265430b | ||
|
|
a8290e41f3 | ||
|
|
343ebe14ea | ||
|
|
31dcbae1da | ||
|
|
2330704243 | ||
|
|
56bf77001c | ||
|
|
d8f653382b | ||
| afa274b651 | |||
| 9a201e7412 | |||
|
|
fee04826c9 | ||
|
|
ae88addcfd | ||
|
|
119d598c24 | ||
|
|
c227c69aaf | ||
|
|
874c0694ba | ||
|
|
671ab3c037 | ||
|
|
5f5e5d1461 | ||
| 42d352c0f6 | |||
|
|
2ee163cba7 | ||
| 378ea441f6 | |||
| 4db9172fc8 | |||
| 825db14e0f | |||
| cfd6691eba |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,6 @@
|
||||
/node_modules
|
||||
.DS_Store
|
||||
/.cache
|
||||
/.idea
|
||||
/assets
|
||||
.zip
|
||||
19
README.md
19
README.md
@@ -6,11 +6,15 @@
|
||||
Если нажать на кнопку 🔇 напротив сообщения в беседе, то все сообщения во всех беседах от этого отправителя будут скрыты.
|
||||
|
||||
## Установка:
|
||||
1. Скачать ZIP
|
||||
### Вариант 1
|
||||
Скачать из интернет-магазина Chrome ([ссылка](https://chrome.google.com/webstore/detail/vk-mute/mcnkfnjggkbenehgfelnnkklpkpjeibl)).
|
||||
|
||||
### Вариант 2
|
||||
1. [Скачать ZIP](https://github.com/anatolykopyl/vk-mute/releases)
|
||||
2. Разархивировать в удобное место
|
||||
3. Хром > Настройки > Расширения
|
||||
1. Включить режим разработчика
|
||||
2. Загрузить распакованное, выбрать каталог с расширением (vk-mute-master/extension)
|
||||
2. Загрузить распакованное, выбрать каталог с расширением
|
||||
|
||||
Расширение должно работать во всех браузерах на движке Chromium.
|
||||
|
||||
@@ -18,3 +22,14 @@
|
||||
- Google Chrome
|
||||
- Opera
|
||||
- Brave
|
||||
|
||||
## Разработка:
|
||||
Для живого обновления содержимого каталога `extension` во время работы запускаем:
|
||||
```
|
||||
$ npm run watch
|
||||
```
|
||||
|
||||
Для билда расширения:
|
||||
```
|
||||
$ npm run build
|
||||
```
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 4.3 KiB |
2
extension/dist/background.js
vendored
2
extension/dist/background.js
vendored
File diff suppressed because one or more lines are too long
115
extension/dist/dom.js
vendored
115
extension/dist/dom.js
vendored
File diff suppressed because one or more lines are too long
4
extension/dist/donate.html
vendored
4
extension/dist/donate.html
vendored
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: hsl(207, 90%, 90%);
|
||||
background-color: hsl(207, 90%, 95%);
|
||||
max-width: 700px;
|
||||
margin: auto;
|
||||
padding: 2rem;
|
||||
@@ -50,4 +50,4 @@
|
||||
<span class="wallet"><strong>BTC:</strong> bc1qf4wtp636m6pqcfz0c42t4fdutqrs4unkdpt5r8</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
4
extension/dist/popup.js
vendored
4
extension/dist/popup.js
vendored
File diff suppressed because one or more lines are too long
@@ -6,10 +6,9 @@
|
||||
"128": "assets/icons/icon128.png",
|
||||
"48": "assets/icons/icon48.png"
|
||||
},
|
||||
"version": "1.0",
|
||||
"version": "1.4",
|
||||
"description": "Позволяет заглушить нежелаемых собеседников",
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"declarativeContent",
|
||||
"storage"
|
||||
],
|
||||
|
||||
9083
package-lock.json
generated
9083
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -20,10 +20,11 @@
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.9.0",
|
||||
"@babel/preset-env": "^7.9.5",
|
||||
"babel-loader": "^8.1.0",
|
||||
"css-loader": "^3.5.2",
|
||||
"html-webpack-plugin": "^4.2.0",
|
||||
"babel-loader": "^8.3.0",
|
||||
"css-loader": "^6.7.3",
|
||||
"html-webpack-plugin": "^5.5.0",
|
||||
"style-loader": "^1.1.4",
|
||||
"webpack": "^4.42.1"
|
||||
"webpack": "^5.76.0",
|
||||
"webpack-cli": "^4.7.2"
|
||||
}
|
||||
}
|
||||
|
||||
34
src/dom/controls.js
vendored
34
src/dom/controls.js
vendored
@@ -9,15 +9,16 @@ function muteBtnHTML(id) {
|
||||
const element = document.createElement('span');
|
||||
element.setAttribute('class', 'mute_message');
|
||||
element.setAttribute('id', `mute${id}`);
|
||||
element.setAttribute('label', 'Заглушить');
|
||||
element.style.background = `url(${chrome.runtime.getURL("assets/mute.png")}) center no-repeat`;
|
||||
element.innerHTML ='<span class="mutetooltip">Заглушить</span>';
|
||||
element.innerHTML = '<div class="mute_tooltip tt_w tt_black tt_down"><div class="tt_text">Заглушить</div></div>';
|
||||
return element;
|
||||
}
|
||||
|
||||
export function tryToAddControls(target) {
|
||||
if (target.className === 'im-mess--check fl_l') {
|
||||
const message = target.parentElement;
|
||||
addControlButton(message)
|
||||
addControlButton(message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +67,11 @@ function setIdToHideHandle() {
|
||||
name: clickedName
|
||||
});
|
||||
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
||||
hideExistingMessages();
|
||||
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||
if (data.isExtensionOn) {
|
||||
hideExistingMessages();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -99,15 +104,18 @@ export function createTryToInitInterval() {
|
||||
* @param message {HTMLElement}
|
||||
*/
|
||||
function addControlButton(message) {
|
||||
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
|
||||
if (actionsArea && actionsArea.lastChild.className !== "mute_message") {
|
||||
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
|
||||
const muteBtn = addMuteButton(actionsArea, senderId);
|
||||
addActionAreaEvents(actionsArea);
|
||||
muteBtn.addEventListener("click", setIdToHideHandle());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
// Check if message is not an outgoing one
|
||||
if (!message.classList.contains('im-mess_out')) {
|
||||
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
|
||||
if (actionsArea && actionsArea.lastChild.className !== "mute_message") {
|
||||
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
|
||||
const muteBtn = addMuteButton(actionsArea, senderId);
|
||||
addActionAreaEvents(actionsArea);
|
||||
muteBtn.addEventListener("click", setIdToHideHandle());
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +127,7 @@ export function tryToInitControls() {
|
||||
if (item.className.includes('im-mess-stack _im_mess_stack')) {
|
||||
let messages = item.children[1].children[1].getElementsByClassName('im-mess _im_mess');
|
||||
for (let message of messages) {
|
||||
status = addControlButton(message, chatBody)
|
||||
status = addControlButton(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,28 @@
|
||||
.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 */
|
||||
.mute_tooltip {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
bottom: 110%;
|
||||
margin-left: -53px;
|
||||
|
||||
/* Fade in tooltip */
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s;
|
||||
left: -50px;
|
||||
top: -33px;
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
.mute_tooltip::after {
|
||||
left: 61px !important;
|
||||
}
|
||||
|
||||
/* Show the tooltip text when you mouse over the tooltip container */
|
||||
.mute_message:hover .mutetooltip {
|
||||
visibility: visible;
|
||||
.mute_message:hover .mute_tooltip {
|
||||
display: block !important;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.mute_message {
|
||||
margin-top: .46rem;
|
||||
margin-left: 4px;
|
||||
margin-right: 3px;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
background-size: contain !important;
|
||||
padding-top: 2px;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background-size: 11px !important;
|
||||
}
|
||||
|
||||
.im-mess--actions {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {getChatBody} from "../utils/getChatBody";
|
||||
import {tryToAddControls} from "./controls";
|
||||
import {tryToAddControls, hideExistingMessages} from "./controls";
|
||||
|
||||
export function addNewMessageEventListener() {
|
||||
const chatBody = getChatBody();
|
||||
@@ -21,4 +21,38 @@ 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,7 +9,12 @@ function init() {
|
||||
if (tryToInitControls()) {
|
||||
createTryToInitInterval();
|
||||
addNewMessageEventListener();
|
||||
hideExistingMessages();
|
||||
returnMessagesEventListener();
|
||||
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||
if (data.isExtensionOn) {
|
||||
hideExistingMessages();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: hsl(207, 90%, 90%);
|
||||
background-color: hsl(207, 90%, 95%);
|
||||
max-width: 700px;
|
||||
margin: auto;
|
||||
padding: 2rem;
|
||||
@@ -50,4 +50,4 @@
|
||||
<span class="wallet"><strong>BTC:</strong> bc1qf4wtp636m6pqcfz0c42t4fdutqrs4unkdpt5r8</span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
body {
|
||||
min-width: 160px;
|
||||
margin: 0;
|
||||
}
|
||||
/* The switch - the box around the slider */
|
||||
.switch {
|
||||
@@ -71,19 +72,17 @@ input:checked + .slider:before {
|
||||
.header {
|
||||
background-color: #2196F3;
|
||||
color: white;
|
||||
width: 100vw;
|
||||
width: 100%;
|
||||
height: 3rem;
|
||||
position: relative;
|
||||
margin-left: -50vw;
|
||||
left: 50%;
|
||||
margin-top: -20vw;
|
||||
margin-bottom: 10vw;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
h3 {
|
||||
margin-bottom: 0;
|
||||
padding: 1rem 0 .5rem 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.idToHide {
|
||||
@@ -92,28 +91,32 @@ h3 {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
background-color: #fff;
|
||||
width: 100vw;
|
||||
}
|
||||
|
||||
.idToHide:hover {
|
||||
background-color: #dcdfde;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
#id_list {
|
||||
color: black;
|
||||
position: relative;
|
||||
margin-left: -50vw;
|
||||
left: 50%;
|
||||
margin-top: 10vw;
|
||||
width: 100%;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
.del_item {
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.del_item:hover {
|
||||
transform: scale(1.15);
|
||||
}
|
||||
|
||||
.donation_btn {
|
||||
text-align: right;
|
||||
margin-top: .5rem;
|
||||
padding: 0 10px 10px 0;
|
||||
}
|
||||
|
||||
a {
|
||||
|
||||
Reference in New Issue
Block a user