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

Commit

Permalink
Add Youtube webcompat webextension (#1047)
Browse files Browse the repository at this point in the history
  • Loading branch information
MortimerGoro authored Mar 29, 2019
1 parent 5c6e7ff commit 525310d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.mozilla.geckoview.GeckoSession.SessionState;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.geckoview.MediaElement;
import org.mozilla.geckoview.WebExtension;
import org.mozilla.geckoview.WebRequestError;
import org.mozilla.vrbrowser.BuildConfig;
import org.mozilla.vrbrowser.R;
Expand Down Expand Up @@ -72,6 +73,7 @@ public static SessionStore get() {
// You can test a local file using: "resource://android/assets/webvr/index.html"
public static final String PRIVATE_BROWSING_URI = "about:privatebrowsing";
public static final int NO_SESSION_ID = -1;
private static final String[] WEB_EXTENSIONS = new String[] {"youtube_webcompat"};

private LinkedList<GeckoSession.NavigationDelegate> mNavigationListeners;
private LinkedList<GeckoSession.ProgressDelegate> mProgressListeners;
Expand Down Expand Up @@ -179,6 +181,10 @@ public void setContext(Context aContext, Bundle aExtras) {
}

mRuntime = GeckoRuntime.create(aContext, runtimeSettingsBuilder.build());
for (String extension: WEB_EXTENSIONS) {
String path = "resource://android/assets/web_extensions/" + extension + "/";
mRuntime.registerWebExtension(new WebExtension(path));
}

} else {
mRuntime.attachTo(aContext);
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/assets/web_extensions/youtube_webcompat/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
div.alert-with-button-renderer {
display:none;
}
8 changes: 8 additions & 0 deletions app/src/main/assets/web_extensions/youtube_webcompat/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Add meta-viewport
let viewport = document.head.querySelector("meta[name='viewport']");
if (!viewport) {
viewport = document.createElement("meta");
viewport.name = "viewport";
viewport.content = "width=user-width, initial-scale=1";
document.head.appendChild(viewport);
}
14 changes: 14 additions & 0 deletions app/src/main/assets/web_extensions/youtube_webcompat/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"manifest_version": 2,
"name": "YoutubeWebCompat",
"version": "1.0",
"description": "Youtube web compat fixes for Firefox Reality",
"content_scripts": [
{
"matches": ["*://*.youtube.com/*"],
"css": ["main.css"],
"js": ["main.js"],
"run_at": "document_end"
}
]
}

0 comments on commit 525310d

Please sign in to comment.