mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-12 19:01:47 +00:00
lint
This commit is contained in:
@ -1,28 +1,28 @@
|
||||
const { ipcRenderer } = require("electron");
|
||||
|
||||
// Override specific listeners of volume-slider by modifying Element.prototype
|
||||
function overrideAddEventListener(){
|
||||
function overrideAddEventListener() {
|
||||
// Events to ignore
|
||||
const nativeEvents = ["mousewheel", "keydown", "keyup"];
|
||||
// Save native addEventListener
|
||||
Element.prototype._addEventListener = Element.prototype.addEventListener;
|
||||
|
||||
Element.prototype.addEventListener = function(type,listener,useCapture=false) {
|
||||
if(this.tagName === "TP-YT-PAPER-SLIDER") { //tagName of #volume-slider
|
||||
Element.prototype._addEventListener = Element.prototype.addEventListener;
|
||||
// Override addEventListener to Ignore specific events in volume-slider
|
||||
Element.prototype.addEventListener = function (type, listener, useCapture = false) {
|
||||
if (this.tagName === "TP-YT-PAPER-SLIDER") { // tagName of #volume-slider
|
||||
for (const eventType of nativeEvents) {
|
||||
if (eventType === type) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} //else
|
||||
this._addEventListener(type,listener,useCapture);
|
||||
}//else
|
||||
this._addEventListener(type, listener, useCapture);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = () => {
|
||||
overrideAddEventListener();
|
||||
// Restore the listeners after load to avoid keeping Element.prototype altered
|
||||
// Restore original function after did-finish-load to avoid keeping Element.prototype altered
|
||||
ipcRenderer.once("restoreAddEventListener", () => { //called from Main to make sure page is completly loaded
|
||||
Element.prototype.addEventListener = Element.prototype._addEventListener;
|
||||
});
|
||||
}
|
||||
Element.prototype.addEventListener = Element.prototype._addEventListener;
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user