mirror of
https://github.com/anatolykopyl/vk-mute.git
synced 2026-03-26 12:55:13 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 378ea441f6 | |||
| 4db9172fc8 | |||
| 825db14e0f | |||
| cfd6691eba |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
/node_modules
|
/node_modules
|
||||||
/.cache
|
/.cache
|
||||||
/.idea
|
/.idea
|
||||||
|
/assets
|
||||||
.zip
|
.zip
|
||||||
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 {
|
.container {
|
||||||
background-color: hsl(207, 90%, 90%);
|
background-color: hsl(207, 90%, 95%);
|
||||||
max-width: 700px;
|
max-width: 700px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
@@ -50,4 +50,4 @@
|
|||||||
<span class="wallet"><strong>BTC:</strong> bc1qf4wtp636m6pqcfz0c42t4fdutqrs4unkdpt5r8</span>
|
<span class="wallet"><strong>BTC:</strong> bc1qf4wtp636m6pqcfz0c42t4fdutqrs4unkdpt5r8</span>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</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",
|
"128": "assets/icons/icon128.png",
|
||||||
"48": "assets/icons/icon48.png"
|
"48": "assets/icons/icon48.png"
|
||||||
},
|
},
|
||||||
"version": "1.0",
|
"version": "1.2",
|
||||||
"description": "Позволяет заглушить нежелаемых собеседников",
|
"description": "Позволяет заглушить нежелаемых собеседников",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab",
|
|
||||||
"declarativeContent",
|
"declarativeContent",
|
||||||
"storage"
|
"storage"
|
||||||
],
|
],
|
||||||
|
|||||||
859
package-lock.json
generated
859
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -24,6 +24,7 @@
|
|||||||
"css-loader": "^3.5.2",
|
"css-loader": "^3.5.2",
|
||||||
"html-webpack-plugin": "^4.2.0",
|
"html-webpack-plugin": "^4.2.0",
|
||||||
"style-loader": "^1.1.4",
|
"style-loader": "^1.1.4",
|
||||||
"webpack": "^4.42.1"
|
"webpack": "^4.42.1",
|
||||||
|
"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');
|
const element = document.createElement('span');
|
||||||
element.setAttribute('class', 'mute_message');
|
element.setAttribute('class', 'mute_message');
|
||||||
element.setAttribute('id', `mute${id}`);
|
element.setAttribute('id', `mute${id}`);
|
||||||
|
element.setAttribute('label', 'Заглушить');
|
||||||
element.style.background = `url(${chrome.runtime.getURL("assets/mute.png")}) center no-repeat`;
|
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;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
addControlButton(message)
|
addControlButton(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +67,11 @@ function setIdToHideHandle() {
|
|||||||
name: clickedName
|
name: clickedName
|
||||||
});
|
});
|
||||||
chrome.storage.sync.set({idsToHide: idsToHide}, function () {
|
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}
|
* @param message {HTMLElement}
|
||||||
*/
|
*/
|
||||||
function addControlButton(message) {
|
function addControlButton(message) {
|
||||||
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
|
// Check if message is not an outgoing one
|
||||||
if (actionsArea && actionsArea.lastChild.className !== "mute_message") {
|
if (!message.classList.contains('im-mess_out')) {
|
||||||
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
|
const actionsArea = message.getElementsByClassName("im-mess--actions")[0];
|
||||||
const muteBtn = addMuteButton(actionsArea, senderId);
|
if (actionsArea && actionsArea.lastChild.className !== "mute_message") {
|
||||||
addActionAreaEvents(actionsArea);
|
const senderId = message.parentElement.parentElement.parentElement["dataset"].peer;
|
||||||
muteBtn.addEventListener("click", setIdToHideHandle());
|
const muteBtn = addMuteButton(actionsArea, senderId);
|
||||||
return true;
|
addActionAreaEvents(actionsArea);
|
||||||
} else {
|
muteBtn.addEventListener("click", setIdToHideHandle());
|
||||||
return false;
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,7 +127,7 @@ export function tryToInitControls() {
|
|||||||
if (item.className.includes('im-mess-stack _im_mess_stack')) {
|
if (item.className.includes('im-mess-stack _im_mess_stack')) {
|
||||||
let messages = item.children[1].children[1].getElementsByClassName('im-mess _im_mess');
|
let messages = item.children[1].children[1].getElementsByClassName('im-mess _im_mess');
|
||||||
for (let message of messages) {
|
for (let message of messages) {
|
||||||
status = addControlButton(message, chatBody)
|
status = addControlButton(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,50 +1,28 @@
|
|||||||
.mute_message .mutetooltip {
|
.mute_tooltip {
|
||||||
visibility: hidden;
|
|
||||||
width: 120px;
|
|
||||||
background-color: #555;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
padding: 5px 0;
|
|
||||||
border-radius: 6px;
|
|
||||||
|
|
||||||
/* Position the tooltip text */
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
z-index: 1;
|
left: -50px;
|
||||||
bottom: 110%;
|
top: -33px;
|
||||||
margin-left: -53px;
|
display: none;
|
||||||
|
|
||||||
/* Fade in tooltip */
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.3s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tooltip arrow */
|
.mute_tooltip::after {
|
||||||
.mute_message .mutetooltip::after {
|
left: 61px !important;
|
||||||
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 */
|
/* Show the tooltip text when you mouse over the tooltip container */
|
||||||
.mute_message:hover .mutetooltip {
|
.mute_message:hover .mute_tooltip {
|
||||||
visibility: visible;
|
display: block !important;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mute_message {
|
.mute_message {
|
||||||
margin-top: .46rem;
|
position: relative;
|
||||||
margin-left: 4px;
|
|
||||||
margin-right: 3px;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
width: 12px;
|
padding-top: 2px;
|
||||||
height: 12px;
|
width: 24px;
|
||||||
background-size: contain !important;
|
height: 24px;
|
||||||
|
background-size: 11px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.im-mess--actions {
|
.im-mess--actions {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import {getChatBody} from "../utils/getChatBody";
|
import {getChatBody} from "../utils/getChatBody";
|
||||||
import {tryToAddControls} from "./controls";
|
import {tryToAddControls, hideExistingMessages} from "./controls";
|
||||||
|
|
||||||
export function addNewMessageEventListener() {
|
export function addNewMessageEventListener() {
|
||||||
const chatBody = getChatBody();
|
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 './dom.css'
|
||||||
import {createTryToInitInterval, hideExistingMessages, tryToInitControls} from "./controls";
|
import {createTryToInitInterval, hideExistingMessages, tryToInitControls} from "./controls";
|
||||||
import {UrlController} from "../utils/Url";
|
import {UrlController} from "../utils/Url";
|
||||||
import {addNewMessageEventListener} from "./hide_element";
|
import {addNewMessageEventListener, returnMessagesEventListener} from "./hide_element";
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
const url = new UrlController();
|
const url = new UrlController();
|
||||||
@@ -9,7 +9,12 @@ function init() {
|
|||||||
if (tryToInitControls()) {
|
if (tryToInitControls()) {
|
||||||
createTryToInitInterval();
|
createTryToInitInterval();
|
||||||
addNewMessageEventListener();
|
addNewMessageEventListener();
|
||||||
hideExistingMessages();
|
returnMessagesEventListener();
|
||||||
|
chrome.storage.sync.get('isExtensionOn', function(data) {
|
||||||
|
if (data.isExtensionOn) {
|
||||||
|
hideExistingMessages();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
background-color: hsl(207, 90%, 90%);
|
background-color: hsl(207, 90%, 95%);
|
||||||
max-width: 700px;
|
max-width: 700px;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
@@ -50,4 +50,4 @@
|
|||||||
<span class="wallet"><strong>BTC:</strong> bc1qf4wtp636m6pqcfz0c42t4fdutqrs4unkdpt5r8</span>
|
<span class="wallet"><strong>BTC:</strong> bc1qf4wtp636m6pqcfz0c42t4fdutqrs4unkdpt5r8</span>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ h3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.idToHide:hover {
|
.idToHide:hover {
|
||||||
background-color: #dcdfde;
|
background-color: #f1f1f1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#id_list {
|
#id_list {
|
||||||
@@ -109,6 +109,11 @@ h3 {
|
|||||||
|
|
||||||
.del_item {
|
.del_item {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.del_item:hover {
|
||||||
|
transform: scale(1.15);
|
||||||
}
|
}
|
||||||
|
|
||||||
.donation_btn {
|
.donation_btn {
|
||||||
|
|||||||
Reference in New Issue
Block a user