-
Notifications
You must be signed in to change notification settings - Fork 569
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into custom-electron-prompt
- Loading branch information
Showing
16 changed files
with
199 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,33 @@ | ||
const { ipcRenderer } = require("electron"); | ||
const is = require("electron-is"); | ||
|
||
let ignored = { | ||
id: ["volume-slider", "expand-volume-slider"], | ||
types: ["mousewheel", "keydown", "keyup"] | ||
}; | ||
|
||
// Override specific listeners of volume-slider by modifying Element.prototype | ||
function overrideAddEventListener() { | ||
// Events to ignore | ||
const nativeEvents = ["mousewheel", "keydown", "keyup"]; | ||
// Save native addEventListener | ||
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); | ||
if (!( | ||
ignored.id.includes(this.id) && | ||
ignored.types.includes(type) | ||
)) { | ||
this._addEventListener(type, listener, useCapture); | ||
} else if (is.dev()) { | ||
console.log(`Ignoring event: "${this.id}.${type}()"`); | ||
} | ||
}; | ||
} | ||
|
||
module.exports = () => { | ||
overrideAddEventListener(); | ||
// 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 | ||
ipcRenderer.once("restoreAddEventListener", () => { // Called from main to make sure page is completly loaded | ||
Element.prototype.addEventListener = Element.prototype._addEventListener; | ||
Element.prototype._addEventListener = undefined; | ||
ignored = undefined; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.