Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Set youtube viewport before DOMContentLoaded #2596

Merged
merged 3 commits into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,15 @@ private void restore() {
loadDefaultPage();
} else if (mState.mSessionState != null) {
mState.mSession.restoreState(mState.mSessionState);
if (mState.mUri != null && mState.mUri.contains(".youtube.com")) {
mState.mSession.loadUri(mState.mUri, GeckoSession.LOAD_FLAGS_REPLACE_HISTORY);
}
} else if (mState.mUri != null) {
mState.mSession.loadUri(mState.mUri);
} else {
loadDefaultPage();
}

if (mState.mUri != null && mState.mUri.contains(".youtube.com")) {
mState.mSession.loadUri(mState.mUri, GeckoSession.LOAD_FLAGS_REPLACE_HISTORY);
}

dumpAllState();
mState.setActive(true);
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/assets/userAgentOverride.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"744723238cc3c00582d7ff9e8ece83e6503a3926d8c07491672d5da3634be41e1d41580dd3694b663c0d0a5e64280a2b411a1346e6ed0d53d694835781cf6436": "Mozilla/5.0 (X11; Linux x86_64; rv:69) Gecko/20100101 Firefox/69.0",
"ae0755740e4354ac67025056e775ad06d8a529ae4f37244fbb02d72199e2c780311e47aa9895079b980ec4bfa676f1f39c4ab41ea995c524e52bde9a73623da2": "Mozilla/5.0 (Linux; Android 7.1.1; Quest) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/7.0.13.186866463 SamsungBrowser/4.0 Chrome/77.0.3865.126 Mobile VR Safari/537.36",
"e6137b4c2f49a3917c2c90a50fb270a5eebb962f2c72344ae2e29e321bb21891e5ca4fec06cae78e14f4a8510473e934234e9ec3f60e8415f5f6da754c55b9b1": "Mozilla/5.0 (Linux; Android 7.1.1; Quest) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/7.0.13.186866463 SamsungBrowser/4.0 Chrome/77.0.3865.126 Mobile VR Safari/537.36"
}

7 changes: 4 additions & 3 deletions app/src/main/assets/web_extensions/webcompat_youtube/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ class YoutubeExtension {
if (viewport) {
viewport.setAttribute('content', content);
} else {
document.head.insertAdjacentHTML('afterbegin', `<meta name="viewport" content="${content}"/>`);
const container = document.head || document.documentElement;
container.insertAdjacentHTML('afterbegin', `<meta name="viewport" content="${content}"/>`);
}
logDebug(`Youtube viewport updated`);
logDebug(`Youtube viewport updated: ${window.innerWidth}x${window.innerHeight} `);
}

// Select a better youtube video quality
Expand Down Expand Up @@ -203,7 +204,7 @@ class YoutubeExtension {
logDebug(`Initializing youtube extension in frame: ${window.location.href}`);
const youtube = new YoutubeExtension();
youtube.overrideUA();
window.addEventListener('DOMContentLoaded', () => youtube.overrideViewport());
youtube.overrideViewport();
window.addEventListener('load', () => {
logDebug('page load');
youtube.overrideVideoProjection();
Expand Down