mirror of
https://github.com/SoPat712/videospeed.git
synced 2025-08-22 02:18:45 -04:00
refactor code. create getController
This commit is contained in:
15
inject.js
15
inject.js
@@ -180,9 +180,7 @@
|
|||||||
var observer=new MutationObserver((mutations) => {
|
var observer=new MutationObserver((mutations) => {
|
||||||
mutations.forEach((mutation) => {
|
mutations.forEach((mutation) => {
|
||||||
if (mutation.type === 'attributes' && (mutation.attributeName === 'src' || mutation.attributeName === 'currentSrc')){
|
if (mutation.type === 'attributes' && (mutation.attributeName === 'src' || mutation.attributeName === 'currentSrc')){
|
||||||
var controller = getShadow(document.body).filter(x => {
|
var controller = getController(this.id)
|
||||||
return x.attributes['data-vscid'] && x.tagName == 'DIV' && x.attributes['data-vscid'].value==`${this.id}`
|
|
||||||
})[0]
|
|
||||||
if(!controller){
|
if(!controller){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -356,6 +354,13 @@
|
|||||||
getChild(parent)
|
getChild(parent)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
function getController(id){
|
||||||
|
return getShadow(document.body).filter(x => {
|
||||||
|
return x.attributes['data-vscid'] &&
|
||||||
|
x.tagName == 'DIV' &&
|
||||||
|
x.attributes['data-vscid'].value==`${id}`
|
||||||
|
})[0]
|
||||||
|
}
|
||||||
|
|
||||||
function initializeNow(document) {
|
function initializeNow(document) {
|
||||||
if (!tc.settings.enabled) return;
|
if (!tc.settings.enabled) return;
|
||||||
@@ -518,9 +523,7 @@
|
|||||||
|
|
||||||
mediaTags.forEach(function(v) {
|
mediaTags.forEach(function(v) {
|
||||||
var id = v.dataset['vscid'];
|
var id = v.dataset['vscid'];
|
||||||
var controller = getShadow(document.body).filter(x => {
|
var controller = getController(id)
|
||||||
return x.attributes['data-vscid'] && x.tagName == 'DIV' && x.attributes['data-vscid'].value==`${id}`
|
|
||||||
})[0]
|
|
||||||
// Don't change video speed if the video has a different controller
|
// Don't change video speed if the video has a different controller
|
||||||
if (e && !(targetController == controller)) {
|
if (e && !(targetController == controller)) {
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user