mirror of
https://github.com/Ujwal223/FocusGram.git
synced 2026-05-27 09:22:32 +02:00
V2 Release
This commit is contained in:
@@ -451,18 +451,40 @@ const String kHideSuggestedPostsJS = r'''
|
||||
(function() {
|
||||
function hideSuggestedPosts() {
|
||||
try {
|
||||
document.querySelectorAll('span, h3, h4').forEach(function(el) {
|
||||
// Target text patterns that indicate suggested content
|
||||
const suggestedPatterns = [
|
||||
'Suggested for you',
|
||||
'Suggested posts',
|
||||
"You're all caught up",
|
||||
'Suggested',
|
||||
'Recommendations',
|
||||
'Discover more',
|
||||
'Suggested Accounts',
|
||||
];
|
||||
|
||||
// Find and hide all elements with suggested content text
|
||||
document.querySelectorAll('span, h3, h4, h2, a').forEach(function(el) {
|
||||
try {
|
||||
const text = el.textContent.trim();
|
||||
if (
|
||||
text === 'Suggested for you' ||
|
||||
text === 'Suggested posts' ||
|
||||
text === "You're all caught up"
|
||||
) {
|
||||
const matched = suggestedPatterns.some(pattern =>
|
||||
text === pattern || text.includes(pattern)
|
||||
);
|
||||
|
||||
if (matched) {
|
||||
let parent = el.parentElement;
|
||||
for (let i = 0; i < 8 && parent; i++) {
|
||||
// Traverse up to find the container section/article
|
||||
for (let i = 0; i < 12 && parent; i++) {
|
||||
const tag = parent.tagName.toLowerCase();
|
||||
if (tag === 'article' || tag === 'section' || tag === 'li') {
|
||||
const classList = parent.className || '';
|
||||
|
||||
// Hide articles, sections, lists, and common suggestion containers
|
||||
if (
|
||||
tag === 'article' ||
|
||||
tag === 'section' ||
|
||||
tag === 'li' ||
|
||||
classList.includes('xjx87jv0') || // Instagram suggestion container
|
||||
classList.includes('x1a8lsjc') // Reel suggestion container
|
||||
) {
|
||||
parent.style.setProperty('display', 'none', 'important');
|
||||
break;
|
||||
}
|
||||
@@ -471,6 +493,21 @@ const String kHideSuggestedPostsJS = r'''
|
||||
}
|
||||
} catch(_) {}
|
||||
});
|
||||
|
||||
// Also hide by attribute patterns
|
||||
document.querySelectorAll('[aria-label*="Suggested"], [data-testid*="suggested"]').forEach(function(el) {
|
||||
try {
|
||||
let parent = el;
|
||||
for (let i = 0; i < 12 && parent; i++) {
|
||||
const tag = parent.tagName.toLowerCase();
|
||||
if (tag === 'article' || tag === 'section' || tag === 'li') {
|
||||
parent.style.setProperty('display', 'none', 'important');
|
||||
break;
|
||||
}
|
||||
parent = parent.parentElement;
|
||||
}
|
||||
} catch(_) {}
|
||||
});
|
||||
} catch(_) {}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,4 +13,3 @@ const String kDmKeyboardFixJS = r'''
|
||||
} catch (_) {}
|
||||
});
|
||||
''';
|
||||
|
||||
|
||||
@@ -78,18 +78,22 @@ List<UserScript> buildUserScripts(FocusSettings settings) {
|
||||
|
||||
final scripts = <UserScript>[];
|
||||
if (startScripts.isNotEmpty) {
|
||||
scripts.add(UserScript(
|
||||
source: startScripts.join('\n'),
|
||||
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START,
|
||||
forMainFrameOnly: false,
|
||||
));
|
||||
scripts.add(
|
||||
UserScript(
|
||||
source: startScripts.join('\n'),
|
||||
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_START,
|
||||
forMainFrameOnly: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (endScripts.isNotEmpty) {
|
||||
scripts.add(UserScript(
|
||||
source: endScripts.join('\n'),
|
||||
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END,
|
||||
forMainFrameOnly: true,
|
||||
));
|
||||
scripts.add(
|
||||
UserScript(
|
||||
source: endScripts.join('\n'),
|
||||
injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END,
|
||||
forMainFrameOnly: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,3 @@ const String kHapticBridgeScript = '''
|
||||
}, true);
|
||||
})();
|
||||
''';
|
||||
|
||||
|
||||
@@ -10,4 +10,3 @@ const String kScrollSmoothingJS = r'''
|
||||
} catch (_) {}
|
||||
})();
|
||||
''';
|
||||
|
||||
|
||||
@@ -29,4 +29,3 @@ const String kSpaNavigationMonitorScript = '''
|
||||
window.addEventListener('popstate', () => notifyUrlChange());
|
||||
})();
|
||||
''';
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ const String kVideoDownloadJS = r'''
|
||||
btn.innerHTML = icon();
|
||||
btn.style.cssText = [
|
||||
'position:absolute',
|
||||
'z-index:2147483647',
|
||||
'z-index:999',
|
||||
'width:34px',
|
||||
'height:34px',
|
||||
'border-radius:10px',
|
||||
|
||||
Reference in New Issue
Block a user