Skip to content
Closed
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ For more versions visit the [relase tab](https://github.com/Kalbra/NoReel/releas
With this feature you can deactivate the reel feed. So you never spend hours scrolling through the feed again wasting your time.
But when friends send you reels, you can only watch them. So only the best content for you.

### Reels in home feed deactivation
Deactivating the reel feed does not stop reels from reaching you: they are also mixed between the normal posts of your home feed, where they
start playing on their own as soon as you scroll past them. With this feature those reels are stopped and removed from the home feed,
so scrolling your feed stays scrolling your feed. Reels that friends send you are untouched.

### Reel scrolling deactivation
A reel a friend sends you opens into the endless reel scroller: one swipe and you are in the algorithm again, which is exactly the
trap [Reel feed deactivation](#reel-feed-deactivation) is meant to close. With this feature you still watch the reel that was sent to you,
but scrolling on to the next one is disabled. Normal scrolling in your chats is not affected.

### Only followed feed
You get content that you are not subscribed to in your home feed? Not if you active Followed feed.
Then you will only be shown content that is really useful to you. The content of your followers, your friends!
Expand Down
65 changes: 64 additions & 1 deletion app/src/main/assets/Injector.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,63 @@ if (article_element){
}
/** END **/

/** home_feed_reels **/
if (document.location.pathname == "/") {
const home_reel_links = document.querySelectorAll('a[href*="/reel/"], a[href*="/reels/audio/"]');
for (var reel_link_index = 0; reel_link_index < home_reel_links.length; reel_link_index++) {
const home_reel_post = home_reel_links[reel_link_index].closest('article');
if (home_reel_post) {
const home_reel_videos = home_reel_post.querySelectorAll('video');
for (var reel_video_index = 0; reel_video_index < home_reel_videos.length; reel_video_index++) {
home_reel_videos[reel_video_index].pause();
home_reel_videos[reel_video_index].muted = true;
}
/* The home feed is a virtualized list. "display: none" removes the layout box, which corrupts Instagram's item bookkeeping and strands the user in blank reserved space while scrolling. Collapsing to a measurable 0px box keeps the feed working. */
const home_reel_style = home_reel_post.style;
home_reel_style.height = "0px";
home_reel_style.minHeight = "0px";
home_reel_style.maxHeight = "0px";
home_reel_style.margin = "0px";
home_reel_style.padding = "0px";
home_reel_style.overflow = "hidden";
}
}
}
/** END **/

/** reel_feed **/
const reel_icon_element = document.querySelector('a[href="/reels/"]');
if (reel_icon_element) {
reel_icon_element.style.display = "none";
}
/** END **/

/** reel_scrolling **/
const reel_scroll_videos = document.querySelectorAll('video');
for (var reel_scroll_index = 0; reel_scroll_index < reel_scroll_videos.length; reel_scroll_index++) {
var reel_scroll_node = reel_scroll_videos[reel_scroll_index].parentElement;
while (reel_scroll_node && reel_scroll_node !== document.body) {
const reel_scroll_height = reel_scroll_node.clientHeight;
const reel_scroll_overflow = window.getComputedStyle(reel_scroll_node).overflowY;
if (reel_scroll_height > 200 && reel_scroll_node.scrollHeight > reel_scroll_height * 2 && (reel_scroll_overflow == "auto" || reel_scroll_overflow == "scroll") && reel_scroll_node.querySelectorAll('video').length > 1) {
/* A reel viewer pages one whole screen at a time, so its direct children are each about as tall as the viewport. A chat message list is not built that way, which keeps normal DM scrolling working. */
var reel_scroll_paged = 0;
for (var reel_child_index = 0; reel_child_index < reel_scroll_node.children.length; reel_child_index++) {
const reel_child_height = reel_scroll_node.children[reel_child_index].getBoundingClientRect().height;
if (reel_child_height > reel_scroll_height * 0.85 && reel_child_height < reel_scroll_height * 1.15) {
reel_scroll_paged++;
}
}
if (reel_scroll_paged > 0) {
reel_scroll_node.style.overflow = "hidden";
break;
}
}
reel_scroll_node = reel_scroll_node.parentElement;
}
}
/** END **/

/** story_strip **/
const story_strip = document.querySelector('div[data-pagelet="story_tray"]');
if (story_strip && !settings_icon) {
Expand All @@ -44,7 +94,20 @@ if (story_strip && !settings_icon) {

/** audio_on **/
try{
document.querySelector('path[d="M1.5 13.3c-.8 0-1.5.7-1.5 1.5v18.4c0 .8.7 1.5 1.5 1.5h8.7l12.9 12.9c.9.9 2.5.3 2.5-1v-9.8c0-.4-.2-.8-.4-1.1l-22-22c-.3-.3-.7-.4-1.1-.4h-.6zm46.8 31.4-5.5-5.5C44.9 36.6 48 31.4 48 24c0-11.4-7.2-17.4-7.2-17.4-.6-.6-1.6-.6-2.2 0L37.2 8c-.6.6-.6 1.6 0 2.2 0 0 5.7 5 5.7 13.8 0 5.4-2.1 9.3-3.8 11.6L35.5 32c1.1-1.7 2.3-4.4 2.3-8 0-6.8-4.1-10.3-4.1-10.3-.6-.6-1.6-.6-2.2 0l-1.4 1.4c-.6.6-.6 1.6 0 2.2 0 0 2.6 2 2.6 6.7 0 1.8-.4 3.2-.9 4.3L25.5 22V1.4c0-1.3-1.6-1.9-2.5-1L13.5 10 3.3-.3c-.6-.6-1.5-.6-2.1 0L-.2 1.1c-.6.6-.6 1.5 0 2.1L4 7.6l26.8 26.8 13.9 13.9c.6.6 1.5.6 2.1 0l1.4-1.4c.7-.6.7-1.6.1-2.2z"]').parentElement.parentElement.click();
if (!window.noreel_audio_enabled) {
const videos = document.querySelectorAll('video');
var audio_is_playing = false;
for (var video_index = 0; video_index < videos.length; video_index++) {
if (!videos[video_index].muted && videos[video_index].volume > 0) {
audio_is_playing = true;
}
}
if (audio_is_playing) {
window.noreel_audio_enabled = true;
} else {
document.querySelector('path[d="M1.5 13.3c-.8 0-1.5.7-1.5 1.5v18.4c0 .8.7 1.5 1.5 1.5h8.7l12.9 12.9c.9.9 2.5.3 2.5-1v-9.8c0-.4-.2-.8-.4-1.1l-22-22c-.3-.3-.7-.4-1.1-.4h-.6zm46.8 31.4-5.5-5.5C44.9 36.6 48 31.4 48 24c0-11.4-7.2-17.4-7.2-17.4-.6-.6-1.6-.6-2.2 0L37.2 8c-.6.6-.6 1.6 0 2.2 0 0 5.7 5 5.7 13.8 0 5.4-2.1 9.3-3.8 11.6L35.5 32c1.1-1.7 2.3-4.4 2.3-8 0-6.8-4.1-10.3-4.1-10.3-.6-.6-1.6-.6-2.2 0l-1.4 1.4c-.6.6-.6 1.6 0 2.2 0 0 2.6 2 2.6 6.7 0 1.8-.4 3.2-.9 4.3L25.5 22V1.4c0-1.3-1.6-1.9-2.5-1L13.5 10 3.3-.3c-.6-.6-1.5-.6-2.1 0L-.2 1.1c-.6.6-.6 1.5 0 2.1L4 7.6l26.8 26.8 13.9 13.9c.6.6 1.5.6 2.1 0l1.4-1.4c.7-.6.7-1.6.1-2.2z"]').parentElement.parentElement.click();
}
}
} catch(e){}
/** END **/

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/example/noreel/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ open class MainActivity : ComponentActivity(), SharedPreferences.OnSharedPrefere
ActivityCompat.requestPermissions(this, arrayOf(readExternalStorage), 23)
}

PreferenceManager.setDefaultValues(this, R.xml.preferences, true)

val preferences = PreferenceManager.getDefaultSharedPreferences(this)
preferences.registerOnSharedPreferenceChangeListener(this)

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
android:key="reel_feed"
android:summary="The feed where short videos / reels are played"
android:defaultValue="false" />
<SwitchPreference
android:title="Reels in home feed"
android:key="home_feed_reels"
android:summary="Reels mixed between the posts of the home feed. Disabling stops them from playing and removes them."
android:defaultValue="false" />
<SwitchPreference
android:title="Reel scrolling"
android:key="reel_scrolling"
android:summary="Scrolling on from one reel to the next, for example after opening a reel someone sent you in a chat. Disabling keeps you on the reel you opened."
android:defaultValue="false" />
<SwitchPreference
android:title="Explore feed"
android:key="search_feed"
Expand Down