Files
YTLitePlus/Extensions/OpenYoutubeSafariExtension.appex/content.js
2023-06-27 09:54:41 +02:00

26 lines
756 B
JavaScript

browser.runtime.sendMessage({ greeting: "hello" }).then((response) => {
console.log("Received response: ", response);
});
browser.runtime.onMessage.addListener((request, sender, sendResponse) => {
console.log("Received request: ", request);
});
function afterNavigate() {
if ('/watch' === location.pathname) {
window.location.href = `youtube://${window.location.pathname.slice(1)}${
window.location.search
}${window.location.hash}`;
}
}
(document.body || document.documentElement).addEventListener('transitionend',
function(/*TransitionEvent*/ event) {
if (event.propertyName === 'width' && event.target.id === 'progress') {
afterNavigate();
}
}, true);
// After page load
afterNavigate();