您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Extract and manage company names from job listings on LinkedIn job search, with immediate blocking and interactive UI for managing blocked companies.
当前为
// ==UserScript== // @name Company Name Extractor with Block List (Enhanced) // @namespace http://tampermonkey.net/ // @version 1.1 // @description Extract and manage company names from job listings on LinkedIn job search, with immediate blocking and interactive UI for managing blocked companies. // @author Daniel Gleason // @match https://www.linkedin.com/jobs/* // @grant GM_setValue // @grant GM_getValue // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to extract and handle job postings based on company block list function handleJobPostings() { const jobPostings = document.querySelectorAll('div[data-job-id]'); jobPostings.forEach(jobPosting => { const companyNameElement = jobPosting.querySelector('span.job-card-container__primary-description'); if (companyNameElement) { const companyName = companyNameElement.innerText.trim(); if (isCompanyBlocked(companyName)) { // Company is blocked, remove the job posting div jobPosting.remove(); } } }); } // Function to check if a company is blocked function isCompanyBlocked(companyName) { const blockedCompanies = getBlockedCompanies(); return blockedCompanies.includes(companyName); } // Function to retrieve blocked companies from storage function getBlockedCompanies() { const blockedCompaniesJSON = GM_getValue('blockedCompanies', '[]'); return JSON.parse(blockedCompaniesJSON); } // Function to save blocked companies to storage function saveBlockedCompanies(blockedCompanies) { const blockedCompaniesJSON = JSON.stringify(blockedCompanies); GM_setValue('blockedCompanies', blockedCompaniesJSON); } // Function to add a company to block list function addCompanyToBlockList(companyName) { let blockedCompanies = getBlockedCompanies(); blockedCompanies.push(companyName.trim()); saveBlockedCompanies(blockedCompanies); } // Function to remove a company from block list function removeCompanyFromBlockList(companyName) { let blockedCompanies = getBlockedCompanies(); const index = blockedCompanies.indexOf(companyName.trim()); if (index !== -1) { blockedCompanies.splice(index, 1); saveBlockedCompanies(blockedCompanies); } } // Function to display the blocked companies UI function displayBlockedCompaniesUI() { const blockedCompanies = getBlockedCompanies(); // Create a table to display blocked companies const table = document.createElement('table'); table.style.borderCollapse = 'collapse'; table.style.marginTop = '20px'; // Add header row const headerRow = table.insertRow(); const nameHeader = headerRow.insertCell(); nameHeader.textContent = 'Company Name'; const actionHeader = headerRow.insertCell(); actionHeader.textContent = 'Action'; // Add rows for each blocked company blockedCompanies.forEach(companyName => { const row = table.insertRow(); const nameCell = row.insertCell(); nameCell.textContent = companyName; const actionCell = row.insertCell(); const removeButton = document.createElement('button'); removeButton.textContent = 'X'; removeButton.style.color = 'red'; removeButton.style.cursor = 'pointer'; removeButton.addEventListener('click', () => { removeCompanyFromBlockList(companyName); row.remove(); // Remove row from table }); actionCell.appendChild(removeButton); }); // Create input field and button for adding new company to block list const inputContainer = document.createElement('div'); inputContainer.style.marginTop = '10px'; inputContainer.style.display = 'flex'; inputContainer.style.alignItems = 'center'; const addCompanyInput = document.createElement('input'); addCompanyInput.placeholder = 'Enter company name'; addCompanyInput.style.marginRight = '10px'; const addButton = document.createElement('button'); addButton.textContent = 'Add to Block List'; addButton.style.cursor = 'pointer'; addButton.style.backgroundColor = '#007bff'; // Blue background color addButton.style.color = 'white'; // White text color addButton.style.border = 'none'; // No border addButton.style.borderRadius = '4px'; // Rounded corners addButton.style.padding = '8px 16px'; // Padding addButton.addEventListener('click', () => { const newCompanyName = addCompanyInput.value.trim(); if (newCompanyName !== '') { addCompanyToBlockList(newCompanyName); addCompanyInput.value = ''; // Clear input field // Refresh the displayed list of blocked companies displayBlockedCompaniesUI(); } }); inputContainer.appendChild(addCompanyInput); inputContainer.appendChild(addButton); // Display the table and input field/button in a modal const modalContent = document.createElement('div'); modalContent.style.position = 'fixed'; modalContent.style.top = '50px'; modalContent.style.left = '50px'; modalContent.style.padding = '20px'; modalContent.style.backgroundColor = 'white'; modalContent.style.border = '1px solid black'; modalContent.style.zIndex = '9999'; modalContent.appendChild(table); modalContent.appendChild(inputContainer); // Add close button const closeButton = document.createElement('button'); closeButton.textContent = 'Close'; closeButton.style.marginTop = '10px'; closeButton.style.cursor = 'pointer'; closeButton.style.backgroundColor = '#dc3545'; closeButton.style.color = 'white'; closeButton.style.border = 'none'; closeButton.style.borderRadius = '4px'; closeButton.style.padding = '8px 16px'; closeButton.addEventListener('click', () => { modalContent.remove(); }); modalContent.appendChild(closeButton); document.body.appendChild(modalContent); } function isPageFullyLoaded() { return document.readyState === 'complete'; } function initInterval() { if (isPageFullyLoaded()) { handleJobPostings(); } else { setTimeout(initInterval, 1000); return; } setInterval(handleJobPostings, 5000); } initInterval(); const showBlockedCompaniesButton = document.createElement('button'); showBlockedCompaniesButton.textContent = 'View Blocked Companies'; showBlockedCompaniesButton.style.position = 'fixed'; showBlockedCompaniesButton.style.top = '20px'; showBlockedCompaniesButton.style.right = '20px'; showBlockedCompaniesButton.style.zIndex = '9999'; showBlockedCompaniesButton.addEventListener('click', displayBlockedCompaniesUI); document.body.appendChild(showBlockedCompaniesButton); })();