Skip to content

Commit

Permalink
Make the extension to remove promoted offers without having to click …
Browse files Browse the repository at this point in the history
…on the extension
  • Loading branch information
yafkari committed Oct 12, 2022
1 parent 5190625 commit 3bd726c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
14 changes: 14 additions & 0 deletions public/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete') {
if (tabId !== -1) {
chrome.storage.local.get(['linkedin-remove-promoted'], function (result) {
if (result['linkedin-remove-promoted'] == true) {
chrome.scripting.executeScript({
target: { tabId },
files: ['content_script.js'],
});
}
});
}
}
});
7 changes: 3 additions & 4 deletions public/content_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ async function removePromotedPosts() {
if (isEmpty || (!isEmpty && value[key] === true)) {
var nodes = document.getElementsByClassName('job-card-container__footer-item inline-flex align-items-center');

Array.from(nodes).filter(node => !node.classList.contains('job-card-container__apply-method')).forEach(element => {
element.parentNode.parentNode.parentNode.parentNode.remove();
})
Array.from(nodes)
.filter(node => !node.classList.contains('job-card-container__apply-method'))
.map(n => n.parentNode.parentNode.parentNode.parentNode.remove());
}
}

removePromotedPosts();
document.addEventListener('DOMNodeInserted', removePromotedPosts);
4 changes: 4 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
"js": ["content_script.js"]
}
],
"background": {
"service_worker": "background.js"
},
"host_permissions": ["*://*.linkedin.com/jobs/search/"],
"permissions": ["storage", "activeTab", "scripting"]
}

0 comments on commit 3bd726c

Please sign in to comment.