Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for facebook mobile site (#100) #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions src/eradicate.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,21 @@ html:not([data-nfe-enabled='false']) {
--notification-badge: var(--base-blue);
}

/* Facebook Mobile */
html:not([data-nfe-enabled='false']) #rootcontainer #root {
position: absolute !important;
opacity: 0 !important;
pointer-events: none !important;
width: 0 !important;
height: 0 !important;
}
html:not([data-nfe-enabled='false']) #rootcontainer #nfe-container {
margin: 15px;
}
[data-sigil='messenger_icon'] > span[data-sigil='count'] {
background-color: #3b5998 !important; /* Use blue instead of red for notification badges */
}

/* Twitter */
html:not([data-nfe-enabled='false']) div[data-testid="primaryColumn"] > div:last-child > div:nth-child(4) > #nfe-container {
padding: 16px;
Expand Down
7 changes: 5 additions & 2 deletions src/intercept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './eradicate.css';
import { setupRouteChange } from './lib/route-change';

import * as FbClassic from './sites/fb-classic';
import * as FbMobile from './sites/fb-mobile';
import * as Fb2020 from './sites/fb-2020';
import * as Twitter from './sites/twitter';
import * as Reddit from './sites/reddit';
Expand Down Expand Up @@ -37,9 +38,11 @@ export function eradicate(store: Store) {
Instagram.eradicate(store);
} else if (FbClassic.checkSite()) {
FbClassic.eradicate(store);
} else {
} else if (FbMobile.checkSite()) {
FbMobile.eradicate(store);
} else {
Fb2020.eradicate(store);
}
}
}

setupRouteChange(store);
Expand Down
2 changes: 2 additions & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"https://www.facebook.com/*",
"http://web.facebook.com/*",
"https://web.facebook.com/*",
"http://m.facebook.com/*",
"https://m.facebook.com/*",
"http://twitter.com/*",
"https://twitter.com/*",
"https://www.reddit.com/",
Expand Down
32 changes: 32 additions & 0 deletions src/sites/fb-mobile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import injectUI, { isAlreadyInjected } from '../lib/inject-ui';
import { isEnabled } from '../lib/is-enabled';
import { Store } from '../store';

export function checkSite(): boolean {
return window.location.host.includes('m.facebook.com');
}

export function eradicate(store: Store) {
function eradicateRetry() {
const settings = store.getState().settings;
if (settings == null || !isEnabled(settings)) {
return;
}

// Don't do anything if the FB UI hasn't loaded yet
const container = document.querySelector('#rootcontainer');

if (container == null) {
return;
}

// Add News Feed Eradicator quote/info panel
if (container && !isAlreadyInjected()) {
injectUI(container, store);
}
}

// This delay ensures that the elements have been created by Facebook's
// scripts before we attempt to replace them
setInterval(eradicateRetry, 1000);
}
3 changes: 3 additions & 0 deletions src/sites/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const Sites: Record<SiteId, Site> = {
'/',
'/home.php',
'/watch',
'/watch/',
'/marketplace/',
'/groups/feed/',
'/gaming/feed/',
Expand All @@ -17,6 +18,8 @@ export const Sites: Record<SiteId, Site> = {
'https://www.facebook.com/*',
'http://web.facebook.com/*',
'https://web.facebook.com/*',
'http://m.facebook.com/*',
'https://m.facebook.com/*',
],
},
instagram: {
Expand Down