bind_fn = [];
control.content_divs.forEach(div => {
bind_fn.push([div, fn]);
div.addEventListener('tap', fn);
});
};
})();
let state = [];
function set_state() {
control.content_divs.forEach((div, i) => state[i] = div.innerText);
}
let start_y, modifier;
const start = e => {
start_y = e.touches[0].screenY;
set_state();
};
const move = e => {
const end_y = e.touches[0].screenY;
const y_distance_px = start_y - end_y;
const increase = Math.floor(px2cm(y_distance_px) * (this.increase_1cm || 1));
const idx = Array.from(e.target.parentElement.children).indexOf(e.target);
if (modifier[idx]) {
modifier[idx](increase);
}
};
const increase_helper = (state_idx, increase,
limit, pre_ele_modifier, wrap = x => x) => {
const v = parseFloat(state[state_idx]) + increase;
if (limit !== undefined) {
if (pre_ele_modifier) {
if (v >= limit) {
pre_ele_modifier(Math.floor(v / limit));
control.content_divs[state_idx].innerText = wrap(v % limit);
} else if (v < 0) {
pre_ele_modifier(-1);
control.content_divs[state_idx].innerText = wrap(limit + v);
} else {
control.content_divs[state_idx].innerText = wrap(v);
}
} else {
control.content_divs[state_idx].innerText =
wrap(Math.min(Math.max(v, 0), limit));
}
} else {
control.content_divs[state_idx].innerText = wrap(v);
}
};
const speed_modifier = [];
speed_modifier[0] = (increase) => {
increase_helper(0, increase);
};
speed_modifier[2] = (increase) => {
increase_helper(2, increase, 10, speed_modifier[0]);
};
speed_modifier[3] = (increase) => {
increase_helper(3, increase, 10, speed_modifier[2]);
};
const jump_modifier = [];
jump_modifier[0] = (increase) => {
increase_helper(0, increase, undefined, undefined, zero_padding);
};
jump_modifier[2] = (increase) => {
increase_helper(2, increase, 60, jump_modifier[0], zero_padding);
};
jump_modifier[4] = (increase) => {
increase_helper(4, increase, 60, jump_modifier[2], zero_padding);
};
speed_div.addEventListener('tap', throttle(e => {
e.stopImmediatePropagation();
clear_content();
const split = video.playbackRate.toString().split('.');
control.content_divs[0].innerText = split[0];
control.content_divs[1].innerText = '.';
control.content_divs[2].innerText = (split[1] || '00').split('')[0] || 0;
control.content_divs[3].innerText = (split[1] || '00').split('')[1] || 0;
control.content_divs[4].innerText = 'x';
modifier = speed_modifier;
set_content_tap_fn(speed_activate);
control.display();
wrap.style.pointerEvents = 'auto';
}, 500));
jump_div.addEventListener('tap', throttle(e => {
e.stopImmediatePropagation();
clear_content();
const time = sec2HHMMSS(video.currentTime);
const split = time.split(':');
if (split.length < 3) {
split.unshift('00');
}
control.content_divs[0].innerText = split[0];
control.content_divs[1].innerText = ':';
control.content_divs[2].innerText = split[1];
control.content_divs[3].innerText = ':';
control.content_divs[4].innerText = split[2];
modifier = jump_modifier;
set_content_tap_fn(jump_activate);
control.display();
wrap.style.pointerEvents = 'auto';
}, 500));
control.content_divs.forEach(div => {
div.addEventListener('touchstart', start, { passive: false });
div.addEventListener('touchmove', move, { passive: false });
});
};
function get_frames(window) {
const frames = [window];
for (let i = 0; i < window.frames.length; i++) {
try {
window.frames[i].document;
} catch {
continue;
}
frames.push(...get_frames(window.frames[i]))
}
return frames;
}
function get_videos() {
const frames = get_frames(window);
const frame_video = frame => Array.from(frame.document.querySelectorAll('video'));
const shadow = frame => Array.from(frame.document.querySelectorAll("shadow-output"));
const shadow_video = shadow => Array.from(shadow.shadowRoot.querySelectorAll("video"));
return flatten(frames.map(frame_video)
.concat(frames.map(f => shadow(f).map(shadow_video))));
}
function find_hook(video) {
window.__hook_video__ = window.__hook_video__ || [];
const exist_video = window.__hook_video__.find(v => v.video === video);
return exist_video;
}
function register_hook(hook) {
if (!find_hook(hook.video)) {
window.__hook_video__.push(hook);
return hook;
}
}
const hook_video = (video) => {
const exist_video = find_hook(video);
if (video.clientWidth && video.clientHeight &&
(!exist_video || is_parent(exist_video.wrap, find_top_wrap_ele(video)))) {
const hook = get_video_touch_hook(video);
hook_video_move(hook);
hook_video_time_change(hook);
hook_video_control(hook);
if (exist_video) {
exist_video.event_clearer.forEach(x => x());
Object.assign(exist_video, hook);
console.log('video-improve: reloaded for ', video, ', wrapped by ', find_top_wrap_ele(video));
} else {
register_hook(hook);
console.log('video-improve: loaded for ', video, ', wrapped by ', find_top_wrap_ele(video));
}
}
};
get_videos().forEach(hook_video);
setInterval(() => {
get_videos().forEach(hook_video);
}, 3000);
}]);return _;}),0;
Back to home |
File page
Subscribe |
Register |
Login
| N