-
Notifications
You must be signed in to change notification settings - Fork 570
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Remove preload.js in plugin uses and use front plugin injection"
This reverts commit 4cb658d.
- Loading branch information
Showing
4 changed files
with
35 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { ipcRenderer } = require("electron"); | ||
|
||
// 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); | ||
}; | ||
} | ||
|
||
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 | ||
Element.prototype.addEventListener = Element.prototype._addEventListener; | ||
}); | ||
}; |
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