diff options
Diffstat (limited to '.config/qutebrowser/greasemonkey/linkedin.js')
-rwxr-xr-x | .config/qutebrowser/greasemonkey/linkedin.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/.config/qutebrowser/greasemonkey/linkedin.js b/.config/qutebrowser/greasemonkey/linkedin.js new file mode 100755 index 0000000..d0eb289 --- /dev/null +++ b/.config/qutebrowser/greasemonkey/linkedin.js @@ -0,0 +1,64 @@ +// ==UserScript== +// @name linkedin css +// @match *://*.linkedin.com/* +// @grant none +// @inject-into content +// ==/UserScript== + +(function() { + 'use strict'; + + // Selectors + const storySelector = '.feed-shared-update-v2'; + const descriptionSelector = '.update-components-text-view'; + + // Search strings + const searchStrings = { + 'da': ['Promoveret'], + 'en': ['Promoted'], + 'es': ['Promocionado'], + 'fr': ['Post sponsorisé'] + }; + + const language = searchStrings.hasOwnProperty(document.documentElement.lang) ? document.documentElement.lang : 'en'; + + function blockSponsoredPosts() { + const stories = document.querySelectorAll(storySelector); + for (const story of stories) { + + // console.log('Handling story', story); + // if (story.style.display == 'none') { + // continue; + // } + + const descriptions = story.querySelectorAll(descriptionSelector); + console.debug('Found descriptions', descriptions); + + for (const description of descriptions) { + console.debug('Handling description', description); + + const descriptionContent = description.innerText.trim(); + if (searchStrings[language].find(searchString => searchString == descriptionContent)) { + + console.debug('Blocked sponsored story', story); + story.style.display = 'none'; + } + } + } + } + + const observer = new MutationObserver(blockSponsoredPosts); + observer.observe(document.body, { + 'childList': true, + 'subtree': true + }); + + blockSponsoredPosts(); + + GM_addStyle(` + .scaffold-layout__aside { + visibility: hidden; + } + `) + +})(); |