njelich/LinkOff

Change sorting preference

ladaflac opened this issue · 4 comments

When I open the LinkedIn feed, I would like the feed to be automatically sorted according to my preference - either Top or Recent.

Manually this is done on desktop LinkedIn by switching the sort dropdown (class="sort-dropdown__icon"). It seems that the selected value is stored for some time in a cookie named feed-sort with values feed (top) or chronFeed (recent).

The extension might do the switch if the preference stored in the extension would be different than the currently selected value. On the other hand, if the current sorting would be equal to the one set in the extension, the extension should not change anything regarding the sorting.

Simply setting the cookie to the correct value works, but the UI updates only after reload.

document.cookie = "feed-sort=chronFeed"

The cookie can be made to not expire by adding properties.

An alternative, or maybe addition to this would be automatically triggering the change to recent.

That would go something like this

// If cookie doesn't match the setting in extension
document.querySelector('button[data-control-name="feed_sort_dropdown_trigger"]').click();

// If setting is top
document.querySelector('button[data-control-name="feed_sort_toggle_relevance"]').click();
// If setting is recent
document.querySelector('button[data-control-name="feed_sort_toggle_chron"]').click();

Resolved by 42784f6 , closing

Need async await, element can take a while to appear

Fixed in 15cc7ad