Skip to content

Commit 8f91edd

Browse files
committed
EOL update: Updated relevant changes from Browser extension version 1.03
1 parent 3e2784c commit 8f91edd

File tree

8 files changed

+67
-11
lines changed

8 files changed

+67
-11
lines changed

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
<img width="100" height="100" src="./src/logo.png" alt="sweeper logo"/>
66
</a>
77

8-
<h2 align="center">FB Mobile - Clean my feeds (UserScript)</h2>
8+
<h2 align="center">FB Mobile - Clean my feeds (UserScript)(EOL)</h2>
99

1010
| [![GreasyFork][GreasyForkShield]](https://greasyfork.org/en/scripts/479868-fb-mobile-clean-my-feeds) | [![GitHub][GitHubShield]](https://github.com/webdevsk/FB-Mobile-Clean-my-feeds) |
1111
|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------|
1212

13+
**⚠️ End of Life for the UserScript**
14+
#### Due to the bloat, compatibility issues with Userscript managers and their instability on Mobile browsers, I've ported this userscript to a standalone Browser Extension ensuring stability, easy installation and additional PWA capabilities. So while this userscript works, I will not be maintaining it anymore.
15+
16+
#### Please refer to the Browser extension repo to install it from your preferred Extension Store (Available in both Chrome Web Store and Mozilla Addon Store for Firefox): [FB Mobile - Clean my feeds (Browser Extension)](https://github.com/webdevsk/fb-mobile-clean-my-feeds-ext/)
17+
1318
</div>
1419

1520
<br />
@@ -88,6 +93,12 @@ Please refer to this link to find other alternatives if my suggested combination
8893

8994

9095
### Changelog
96+
- **v1.03**-EOL
97+
- Updated relevant changes from Browser extension version 1.03
98+
- **v1.02**
99+
- Improved compatibility with other userscript managers that don't support GM_addValueChangeListener api
100+
- **v1.01**
101+
- Improved navigation detection
91102
- **v1.00**
92103
- Source code converted to TypeScript and split into multiple files as it was getting harder to maintain in a single file. Please refer to [Contribution][Contribution] page for more information including the build process.
93104
- Full code overhaul. Made to be more maintainable and easier to understand. As well as easily extendable and efficient on browser performance.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fb-mobile-clean-my-feeds",
3-
"version": "1.02",
3+
"version": "1.03",
44
"author": "https://github.com/webdevsk",
55
"repository": {
66
"type": "git",

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export type MainPagesBasedOnNavBarButtons =
4949
/**
5050
* pages to run the script on
5151
*/
52-
export const runScriptOn: MainPagesBasedOnNavBarButtons[] = ["feed", "videos"]
52+
export const runScriptOn: MainPagesBasedOnNavBarButtons[] = ["feed"]
5353
/**
5454
* showPlaceholder is whether to show placeholder or not
5555
*/

src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ import { registerAutoReloadAfterIdle } from "@/lib/register-auto-reload-after-id
88
import { runFeedsCleaner } from "@/lib/run-feeds-cleaner"
99
import { SettingsMenuInjector } from "@/lib/settings-menu-injector"
1010
import { updateThemeConfigWhenPossible } from "@/lib/updateThemeConfigWhenPossible"
11-
import STYLES from "@/styles/style.css"
11+
import STYLES from "@/style.css"
12+
import { injectConsole } from "@/utils/inject-console"
13+
import { removeAppInstallPrompt } from "@/lib/remove-app-install-prompt"
1214
;(() => {
1315
// Make sure this is the React-Mobile version of facebook
1416
if (document.body.id !== bodyId) {
1517
console.error("ID 'app-body' not found.")
1618
return
1719
}
1820

21+
injectConsole("FB Mobile - Clean my feeds (UserScript)")
22+
GM_addStyle(STYLES)
23+
1924
onReadyForScripting(() => {
2025
console.log("Ready for scripting")
21-
const styleNode = GM_addStyle(STYLES)
26+
27+
removeAppInstallPrompt()
2228
// Store all abort functions
2329
const aborts: Array<() => void> = [
2430
updateThemeConfigWhenPossible(),
@@ -45,7 +51,6 @@ import STYLES from "@/styles/style.css"
4551

4652
return () => {
4753
console.log("Not Ready for scripting")
48-
styleNode.remove()
4954
// Cleanup code like removing dom nodes and destroying event listeners
5055
aborts.forEach(abort => abort?.())
5156
aborts.length = 0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { devMode } from "@/config"
2+
3+
export const removeAppInstallPrompt = () => {
4+
const node = document.querySelector<HTMLDivElement>(
5+
'[data-screen-id]:first-child [data-comp-id~="22222"]'
6+
)
7+
if (!node) {
8+
if (devMode) console.log("App install prompt node status: ", node)
9+
return
10+
}
11+
if (devMode) console.log("Setting styles for App install prompt")
12+
node.style.display = "none"
13+
}

src/lib/settings-menu-injector.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ export class SettingsMenuInjector {
8383
}
8484

8585
private handleDocumentClick = (event: MouseEvent) => {
86-
const target = event.target as HTMLElement
86+
const { target, x, y } = event
87+
if (!(target instanceof HTMLElement)) return
8788

8889
if (target.matches("#settingsBtn")) {
8990
this.show()
@@ -105,6 +106,14 @@ export class SettingsMenuInjector {
105106
target: document.querySelector(screenRootSelector)!,
106107
}
107108
)
109+
} else if (target.matches(`#${this.overlayId}`)) {
110+
const { left, right, top, bottom } = target
111+
.querySelector(".settings-container")!
112+
.getBoundingClientRect()
113+
// When clicked on the empty space
114+
if (!(x >= left && x <= right && y >= top && y <= bottom)) {
115+
this.hide()
116+
}
108117
}
109118
}
110119

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/* DOM fixes */
2+
3+
/* fix comment box height */
4+
textarea[style*="height"] {
5+
height: 100% !important;
6+
}
7+
8+
/* Script styles */
19
.dialog-screen {
210
position: fixed;
311
inset: 0;
@@ -190,10 +198,6 @@ div[data-purged="true"] {
190198
}
191199
}
192200

193-
/* Removes app install prompt */
194-
[data-screen-id]:first-child [data-comp-id~="22222"] {
195-
display: none !important;
196-
}
197201

198202
#block-counter {
199203
position: fixed;

src/utils/inject-console.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const consoleMethodsThatDontBreakWhenArgumentIsString = ["log", "error", "warn", "info", "debug", "trace"]
2+
3+
/** Styles console.log and console.error prefixing the extension name */
4+
export function injectConsole(prefix: string) {
5+
const originalConsole = globalThis.console
6+
globalThis.console = new Proxy(originalConsole, {
7+
get(target, prop, receiver) {
8+
const method = Reflect.get(target, prop, receiver)
9+
return consoleMethodsThatDontBreakWhenArgumentIsString.some((propName) => propName === prop)
10+
? method.bind(target, `[${prefix}]\n`)
11+
: method
12+
},
13+
})
14+
}

0 commit comments

Comments
 (0)