Comments (2)
LinkedIn changed the behaviour of the notifications page.
Posts now link to linkedin.com/feed?highlightUpdateUrn=...
That page shows the post at the top followed by the usual feed.
Two possible solutions: Detect highlightedUpdateUrn
in the query params and
- show only the first item in the feed.
- redirect to the same post at
linkedin.com/posts/...
(would be a faff to find the right url, and possibly prone to breaking)
from news-feed-eradicator.
Here's a userscript to fix this problem:
Click here
// ==UserScript==
// @name Fix LinkedIn notifications page
// @description Fix notification links so they go to the post or activity page instead of the feed.
// @version 2024-01-19
// @match https://www.linkedin.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=linkedin.com
// ==/UserScript==
(() => {
'use strict'
/* Monkey-patch locationchange event */
const oldPushState = history.pushState
history.pushState = function pushState() {
const ret = oldPushState.apply(this, arguments)
window.dispatchEvent(new Event('locationchange'))
return ret
}
const oldReplaceState = history.replaceState
history.replaceState = function replaceState() {
const ret = oldReplaceState.apply(this, arguments)
window.dispatchEvent(new Event('locationchange'))
return ret
}
window.addEventListener('popstate', () =>
window.dispatchEvent(new Event('locationchange')))
/* Listen for notifications page */
continueIfNotificationsPage()
window.addEventListener('locationchange', continueIfNotificationsPage)
async function continueIfNotificationsPage() {
if (!isNotificationsPage()) return
const cardList = await waitForElement({ target: "nt-card-list", ancestor: 'application-outlet' })
changeLinks(cardList)
}
function changeLinks(cardList) {
const initial_notification_elements = cardList.children
// change link for initial 10 loaded notifications
for(const el of initial_notification_elements) changeLink(el)
// change link for any notifications that load later
const listener = mutation_records => mutation_records
.forEach(mr => mr.addedNodes.forEach(node => node.nodeName === 'DIV' && changeLink(node)))
observeMutations({ element: cardList, listener, childList: true })
}
function changeLink (notification_element) {
const link_element = notification_element
.querySelector('a.nt-card__headline')
const url = link_element.attributes.href.value
const newUrl = url
.replace(/^\/feed\/\?highlightedUpdateUrn=urn%3Ali%3Aactivity%3A(\d{19}).*/, '/feed/update/urn:li:activity:$1')
link_element.setAttribute('href', newUrl)
remove_click_events(link_element)
}
/* ... */
function observeMutations({ element, listener, ...options }) {
const observer = new MutationObserver(listener)
observer.observe(element, options)
return observer
}
function waitForElement({ ancestor, target }) {
const ancestorEl = document.getElementsByClassName(ancestor)[0]
const search = ancestorEl.getElementsByClassName(target)
if (search.length > 0)
return Promise.resolve(search[0])
return new Promise(resolve => {
const observer = observeMutations({
listener,
element: ancestorEl,
childList: true,
subtree: true
})
function listener(mutationRecords) {
for (const mutationRecord of mutationRecords) {
for (const node of mutationRecord.addedNodes)
if (node?.classList?.contains?.(target)) {
observer.disconnect()
resolve(node)
}
}}
})
}
// Remove click events overriding the new href
function remove_click_events(element) {
element.outerHTML = element.outerHTML
}
function isNotificationsPage() {
const matchNotificationsPage = /^https:\/\/www\.linkedin\.com\/notifications\/?\??.*$/
return matchNotificationsPage.test(window.location)
}
})()
from news-feed-eradicator.
Related Issues (20)
- X/Twitter only block "For you" news feed?
- Trying to eradicate feeds on Android using Adguard DNS rules
- Change Twitter to "Twitter/X" 😅 HOT 1
- Easily Bypassable with 2 clicks HOT 1
- Add Support for Mobile websites
- Feature request HOT 1
- Add support for eliminating Threads home feed (threads.net)
- Feature request to show limited number of posts
- Not working on reddit. HOT 2
- Feature Request: Snapchat Mobile
- [Issue] Reddit newsfeed remains hidden when turning eradication of HOT 1
- adding feature
- Feature request - paragraph breaks
- Possible bug when pausing eradication on youtube
- I want a feature to add the personilized or custom website to eradict.
- MacOS Safari Extension HOT 1
- Facebook Groups Feed HOT 1
- x.com feed not getting blocked on Windows 11 - Chrome HOT 1
- x.com feed not getting blocked on macOS M1 Brave Browser HOT 1
- X.com not being blocked using Brave on Ubuntu
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from news-feed-eradicator.