Skip to content

Commit

Permalink
got basic functionality working
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert01101101 committed Nov 8, 2024
1 parent 9dbcd17 commit b8ecf2e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
44 changes: 33 additions & 11 deletions source/content.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
import optionsStorage from './options-storage.js';

console.log('💈 Content script loaded for', chrome.runtime.getManifest().name);
console.log('hide-applied-jobs-linkedin - 💈 Content script loaded for', chrome.runtime.getManifest().name);

async function init() {
const options = await optionsStorage.getAll();
const color = `rgb(${options.colorRed}, ${options.colorGreen},${options.colorBlue})`;
const text = options.text;
const notice = document.createElement('div');
notice.innerHTML = text;
document.body.prepend(notice);
notice.id = 'text-notice';
notice.style.border = '2px solid ' + color;
notice.style.color = color;
const options = await optionsStorage.getAll();
const color = `rgb(${options.colorRed}, ${options.colorGreen},${options.colorBlue})`;
const text = options.text;
const notice = document.createElement('div');
notice.innerHTML = text;
document.body.prepend(notice);
notice.id = 'text-notice';
notice.style.border = '2px solid ' + color;
notice.style.color = color;

// Function to hide job items that contain 'Applied'
function hideJobItems() {
const jobItems = document.querySelectorAll('.jobs-search-results__list-item');
console.log(`hide-applied-jobs-linkedin - Found ${jobItems.length} job items to check.`); // Log the number of items found
jobItems.forEach(item => {
// Check if the item contains a child element with the text 'Applied'
const appliedElement = Array.from(item.querySelectorAll('li')).find(li => li.textContent.trim() === 'Applied');
if (appliedElement) {
item.style.display = 'none'; // Hide the job item
console.log('hide-applied-jobs-linkedin - Hiding job item:', item); // Log each item being hidden
}
});
}

// Initial call to hide job items
hideJobItems();

// Set up a MutationObserver to watch for changes in the job listings
const observer = new MutationObserver(hideJobItems);
observer.observe(document.body, { childList: true, subtree: true });
console.log('hide-applied-jobs-linkedin - MutationObserver set up to watch for changes in the DOM.'); // Log that the observer is set up
}

init();
init();
2 changes: 1 addition & 1 deletion source/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
"content_scripts": [
{
"matches": [ "https://github.com/Robert01101101/hide-applied-jobs-linkedin/*" ],
"matches": [ "https://www.linkedin.com/*" ],
"js": [ "content.js" ],
"css": [ "content.css" ],
"run_at": "document_end"
Expand Down

0 comments on commit b8ecf2e

Please sign in to comment.