mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 12:55:13 +00:00
Compare commits
5 Commits
78c6b02214
...
v1.5.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 91f1833534 | |||
|
|
4089f640ea | ||
|
|
85596a95a6 | ||
|
|
4cebd66a85 | ||
|
|
bc49282b62 |
2
.babelrc
2
.babelrc
@@ -1,3 +1,3 @@
|
|||||||
{
|
{
|
||||||
"presets": ["@babel/preset-env"]
|
"presets": ["@babel/preset-env"]
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB |
123
extension/dist/background.js
vendored
123
extension/dist/background.js
vendored
File diff suppressed because one or more lines are too long
1224
extension/dist/dom.js
vendored
1224
extension/dist/dom.js
vendored
File diff suppressed because one or more lines are too long
5
extension/dist/popup.html
vendored
5
extension/dist/popup.html
vendored
@@ -2,12 +2,11 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
</head>
|
<script defer src="popup.js"></script></head>
|
||||||
<body>
|
<body>
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h3 align="center">VK Mute</h3>
|
<h3 align="center">VK Mute</h3>
|
||||||
</div>
|
</div>
|
||||||
<!--<button id="disableButton">Toggle</button>-->
|
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
<input type="checkbox" id="disableCheckbox">
|
<input type="checkbox" id="disableCheckbox">
|
||||||
@@ -19,5 +18,5 @@
|
|||||||
<div class="donation_btn">
|
<div class="donation_btn">
|
||||||
<a href="./donate.html" title="Пожертвовать" target="_blank">💸</a>
|
<a href="./donate.html" title="Пожертвовать" target="_blank">💸</a>
|
||||||
</div>
|
</div>
|
||||||
<script src="popup.js"></script></body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
412
extension/dist/popup.js
vendored
412
extension/dist/popup.js
vendored
File diff suppressed because one or more lines are too long
@@ -6,20 +6,21 @@
|
|||||||
"128": "assets/icons/icon128.png",
|
"128": "assets/icons/icon128.png",
|
||||||
"48": "assets/icons/icon48.png"
|
"48": "assets/icons/icon48.png"
|
||||||
},
|
},
|
||||||
"version": "1.4",
|
"version": "1.5.0",
|
||||||
"description": "Позволяет заглушить нежелаемых собеседников",
|
"description": "Позволяет заглушить нежелаемых собеседников",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"declarativeContent",
|
|
||||||
"storage"
|
"storage"
|
||||||
],
|
],
|
||||||
"background": {
|
"action": {
|
||||||
"scripts": ["dist/background.js"],
|
"default_icon": {
|
||||||
"persistent": false
|
"140": "assets/icons/icon140.png",
|
||||||
},
|
"128": "assets/icons/icon128.png",
|
||||||
"page_action": {
|
"48": "assets/icons/icon48.png"
|
||||||
|
},
|
||||||
|
"default_title": "VK Mute",
|
||||||
"default_popup": "dist/popup.html"
|
"default_popup": "dist/popup.html"
|
||||||
},
|
},
|
||||||
"manifest_version": 2,
|
"manifest_version": 3,
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://*.vk.com/*"],
|
"matches": ["https://*.vk.com/*"],
|
||||||
@@ -27,6 +28,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
"assets/mute.png"
|
{
|
||||||
|
"resources": ["assets/mute.png"],
|
||||||
|
"matches": ["https://*.vk.com/*"]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
680
package-lock.json
generated
680
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "vk-mute",
|
"name": "vk-mute",
|
||||||
"version": "1.0.0",
|
"version": "1.5.0",
|
||||||
"description": "Заглушить собеседника в беседе в ВК. 🔇",
|
"description": "Заглушить собеседника в беседе в ВК. 🔇",
|
||||||
"main": "src/dom/main.js",
|
"main": "src/dom/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/anatolykopyl/vk-mute.git"
|
"url": "git+https://github.com/anatolykopyl/vk-mute.git"
|
||||||
},
|
},
|
||||||
"author": "",
|
"author": "Anatoly Kopyl <hi@kopyl.dev>",
|
||||||
"license": "ISC",
|
"license": "GPL-3.0",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/anatolykopyl/vk-mute/issues"
|
"url": "https://github.com/anatolykopyl/vk-mute/issues"
|
||||||
},
|
},
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
"babel-loader": "^8.3.0",
|
"babel-loader": "^8.3.0",
|
||||||
"css-loader": "^6.7.3",
|
"css-loader": "^6.7.3",
|
||||||
"html-webpack-plugin": "^5.5.0",
|
"html-webpack-plugin": "^5.5.0",
|
||||||
|
"raw-loader": "^4.0.2",
|
||||||
"style-loader": "^1.1.4",
|
"style-loader": "^1.1.4",
|
||||||
"webpack": "^5.76.0",
|
"webpack": "^5.76.0",
|
||||||
"webpack-cli": "^4.7.2"
|
"webpack-cli": "^4.7.2"
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
chrome.runtime.onInstalled.addListener(function () {
|
|
||||||
chrome.storage.sync.set({ isExtensionOn: true }, function () {
|
|
||||||
console.log('isExtensionOn: ' + true);
|
|
||||||
});
|
|
||||||
|
|
||||||
chrome.declarativeContent.onPageChanged.removeRules(undefined, function () {
|
|
||||||
chrome.declarativeContent.onPageChanged.addRules([{
|
|
||||||
conditions: [new chrome.declarativeContent.PageStateMatcher({
|
|
||||||
pageUrl: { hostEquals: 'vk.com' },
|
|
||||||
})],
|
|
||||||
actions: [new chrome.declarativeContent.ShowPageAction()]
|
|
||||||
}]);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
66
src/dom/controls.js
vendored
66
src/dom/controls.js
vendored
@@ -1,20 +1,24 @@
|
|||||||
|
import {getChatBody} from "../utils/getChatBody";
|
||||||
|
import muteSvg from "./mute.svg";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id {String}
|
* @param id {String}
|
||||||
* @return {HTMLSpanElement}
|
* @return {HTMLSpanElement}
|
||||||
*/
|
*/
|
||||||
import {getChatBody} from "../utils/getChatBody";
|
|
||||||
|
|
||||||
function muteBtnHTML(id) {
|
function muteBtnHTML(id) {
|
||||||
const element = document.createElement('span');
|
const element = document.createElement('span');
|
||||||
element.setAttribute('class', 'mute_message');
|
element.setAttribute('class', 'im-mess--mute');
|
||||||
element.setAttribute('id', `mute${id}`);
|
element.setAttribute('id', `mute${id}`);
|
||||||
element.setAttribute('label', 'Заглушить');
|
element.setAttribute('label', 'Заглушить');
|
||||||
element.style.background = `url(${chrome.runtime.getURL("assets/mute.png")}) center no-repeat`;
|
element.innerHTML = muteSvg + '<div class="mute_tooltip tt_w tt_black tt_down"><div class="tt_text">Заглушить</div></div>';
|
||||||
element.innerHTML = '<div class="mute_tooltip tt_w tt_black tt_down"><div class="tt_text">Заглушить</div></div>';
|
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param target {HTMLElenemt}
|
||||||
|
*/
|
||||||
export function tryToAddControls(target) {
|
export function tryToAddControls(target) {
|
||||||
if (target.className === 'im-mess--check fl_l') {
|
if (target.className === 'im-mess--check fl_l') {
|
||||||
const message = target.parentElement;
|
const message = target.parentElement;
|
||||||
@@ -31,7 +35,7 @@ export function tryToAddControls(target) {
|
|||||||
function addMuteButton(actionArea, senderId) {
|
function addMuteButton(actionArea, senderId) {
|
||||||
const muteButton = muteBtnHTML(senderId);
|
const muteButton = muteBtnHTML(senderId);
|
||||||
actionArea.appendChild(muteButton);
|
actionArea.appendChild(muteButton);
|
||||||
muteButton.style.display = "none";
|
muteButton.style.visibility = "hidden";
|
||||||
return muteButton;
|
return muteButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,41 +45,39 @@ function addMuteButton(actionArea, senderId) {
|
|||||||
*/
|
*/
|
||||||
function addActionAreaEvents(actionsArea) {
|
function addActionAreaEvents(actionsArea) {
|
||||||
actionsArea.parentElement.addEventListener("mouseenter", function (event) {
|
actionsArea.parentElement.addEventListener("mouseenter", function (event) {
|
||||||
event.target.getElementsByClassName("mute_message")[0].style.display = "inline-block";
|
event.target.getElementsByClassName("im-mess--mute")[0].style.visibility = "visible";
|
||||||
});
|
});
|
||||||
|
|
||||||
actionsArea.parentElement.addEventListener("mouseleave", function (event) {
|
actionsArea.parentElement.addEventListener("mouseleave", function (event) {
|
||||||
event.target.getElementsByClassName("mute_message")[0].style.display = "none";
|
event.target.getElementsByClassName("im-mess--mute")[0].style.visibility = "hidden";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return {function(...[]=)}
|
* @this {HTMLElement}
|
||||||
*/
|
*/
|
||||||
function setIdToHideHandle() {
|
function setIdToHideHandle() {
|
||||||
return function (event) {
|
const clickedId = this.id.substring(4);
|
||||||
const clickedId = event.target.id.substr(4); // get id of sender from element id
|
let clickedName = this.parentElement.parentElement.parentElement.parentElement;
|
||||||
let clickedName = event.target.parentElement.parentElement.parentElement.parentElement;
|
clickedName = clickedName.children[0].children[0].children[0].innerText;
|
||||||
clickedName = clickedName.children[0].children[0].children[0].innerText;
|
|
||||||
|
|
||||||
chrome.storage.sync.get('idsToHide', function(data) {
|
chrome.storage.sync.get('idsToHide', function(data) {
|
||||||
let idsToHide = data.idsToHide || [];
|
let idsToHide = data.idsToHide || [];
|
||||||
if (idsToHide.filter(user => user.id == clickedId).length === 0) {
|
if (idsToHide.filter(user => user.id == clickedId).length === 0) {
|
||||||
idsToHide.push({
|
idsToHide.push({
|
||||||
id: clickedId,
|
id: clickedId,
|
||||||
name: clickedName
|
name: clickedName
|
||||||
|
});
|
||||||
|
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
||||||
|
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||||
|
if (data.isExtensionOn) {
|
||||||
|
hideExistingMessages();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
});
|
||||||
chrome.storage.sync.get('isExtensionOn', function(data) {
|
}
|
||||||
if (data.isExtensionOn) {
|
});
|
||||||
hideExistingMessages();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hideExistingMessages() {
|
export function hideExistingMessages() {
|
||||||
@@ -107,11 +109,11 @@ function addControlButton(message) {
|
|||||||
// Check if message is not an outgoing one
|
// Check if message is not an outgoing one
|
||||||
if (!message.classList.contains('im-mess_out')) {
|
if (!message.classList.contains('im-mess_out')) {
|
||||||
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
|
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
|
||||||
if (actionsArea && actionsArea.lastChild.className !== "mute_message") {
|
if (actionsArea && actionsArea.lastChild.className !== "im-mess--mute") {
|
||||||
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
|
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
|
||||||
const muteBtn = addMuteButton(actionsArea, senderId);
|
const muteBtn = addMuteButton(actionsArea, senderId);
|
||||||
addActionAreaEvents(actionsArea);
|
addActionAreaEvents(actionsArea);
|
||||||
muteBtn.addEventListener("click", setIdToHideHandle());
|
muteBtn.addEventListener("click", setIdToHideHandle);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@@ -132,4 +134,4 @@ export function tryToInitControls() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,19 +10,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Show the tooltip text when you mouse over the tooltip container */
|
/* Show the tooltip text when you mouse over the tooltip container */
|
||||||
.mute_message:hover .mute_tooltip {
|
.im-mess--mute:hover .mute_tooltip {
|
||||||
display: block !important;
|
display: block !important;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mute_message {
|
.im-mess--mute {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-block;
|
display: inline-flex;
|
||||||
vertical-align: top;
|
align-items: center;
|
||||||
padding-top: 2px;
|
justify-content: center;
|
||||||
width: 24px;
|
width: 24px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
background-size: 11px !important;
|
opacity: .5;
|
||||||
|
color: var(--vkui--color_icon_secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.im-mess--mute:hover {
|
||||||
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.im-mess--actions {
|
.im-mess--actions {
|
||||||
|
|||||||
9
src/dom/mute.svg
Normal file
9
src/dom/mute.svg
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
width="16"
|
||||||
|
height="16"
|
||||||
|
fill="currentColor"
|
||||||
|
viewBox="2 1 13 13"
|
||||||
|
>
|
||||||
|
<path d="M4.69 5.5 11 11.8v1.7c0 .3-.23.47-.49.5l-3.63-3.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1h.69Zm.77-2.85 2.2 2.19L10.5 2.5c.27.02.49.2.49.48v5.2l2.6 2.6a.75.75 0 0 1-1.06 1.06L4.4 3.71a.75.75 0 0 1 1.06-1.06Z"></path>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 348 B |
@@ -7,7 +7,6 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<h3 align="center">VK Mute</h3>
|
<h3 align="center">VK Mute</h3>
|
||||||
</div>
|
</div>
|
||||||
<!--<button id="disableButton">Toggle</button>-->
|
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
<input type="checkbox" id="disableCheckbox">
|
<input type="checkbox" id="disableCheckbox">
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import './popup.css'
|
import './popup.css'
|
||||||
|
|
||||||
//let disableButton = document.getElementById('disableButton');
|
//let disableButton = document.getElementById('disableButton');
|
||||||
let disableCheckbox = document.getElementById('disableCheckbox');
|
const disableCheckbox = document.getElementById('disableCheckbox');
|
||||||
let idsToHideElements = document.getElementsByClassName('idToHide');
|
const idsToHideElements = document.getElementsByClassName('idToHide');
|
||||||
let idList = document.getElementById("id_list");
|
const idList = document.getElementById("id_list");
|
||||||
let isExtensionOn;
|
let isExtensionOn;
|
||||||
let idsToHide = [];
|
let idsToHide = [];
|
||||||
|
|
||||||
@@ -51,4 +51,4 @@ disableCheckbox.addEventListener('change', (event) => {
|
|||||||
chrome.storage.sync.set({isExtensionOn}, function() {
|
chrome.storage.sync.set({isExtensionOn}, function() {
|
||||||
console.log('isExtensionOn: '+isExtensionOn);
|
console.log('isExtensionOn: '+isExtensionOn);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,5 +43,4 @@ export class UrlController {
|
|||||||
clearInterval(this.interval)
|
clearInterval(this.interval)
|
||||||
this.interval = null
|
this.interval = null
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
export function getChatBody() {
|
export function getChatBody() {
|
||||||
return document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
return document.getElementsByClassName("_im_peer_history im-page-chat-contain")[0];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ module.exports = {
|
|||||||
devtool: "inline-source-map",
|
devtool: "inline-source-map",
|
||||||
entry: {
|
entry: {
|
||||||
dom: './src/dom/main.js',
|
dom: './src/dom/main.js',
|
||||||
background: './src/background/background.js',
|
|
||||||
popup: './src/popup/popup.js'
|
popup: './src/popup/popup.js'
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
@@ -28,18 +27,23 @@ module.exports = {
|
|||||||
{
|
{
|
||||||
test: /\.css$/i,
|
test: /\.css$/i,
|
||||||
use: ['style-loader', 'css-loader'],
|
use: ['style-loader', 'css-loader'],
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
test: /\.svg$/i,
|
||||||
|
use: 'raw-loader',
|
||||||
|
},
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
plugins: [new HtmlWebpackPlugin({
|
plugins: [
|
||||||
template: "./src/popup/popup.html",
|
new HtmlWebpackPlugin({
|
||||||
filename: "popup.html",
|
template: "./src/popup/popup.html",
|
||||||
chunks: ['popup']
|
filename: "popup.html",
|
||||||
}),
|
chunks: ['popup']
|
||||||
new HtmlWebpackPlugin({
|
}),
|
||||||
template: "./src/donate.html",
|
new HtmlWebpackPlugin({
|
||||||
filename: "donate.html",
|
template: "./src/donate.html",
|
||||||
chunks: ['donate']
|
filename: "donate.html",
|
||||||
})]
|
chunks: ['donate']
|
||||||
|
})
|
||||||
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user