Skip to content

Commit

Permalink
Added a divider between the WFM input and the rest of the form
Browse files Browse the repository at this point in the history
Added a label to the input
  • Loading branch information
probablyraging committed Sep 10, 2024
1 parent 97d1c93 commit 5e29ad0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
5 changes: 2 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
- Changed extension name to 'Workforce Mate'
- Updated extension icon to suit name change
- Removed unnecessary permission from firefox manifest
- Added a divider between the WFM input and the rest of the form
- Added a label to the input
44 changes: 32 additions & 12 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,65 @@ const retryInterval = 500;
// Initialize the extension
function initializeExtension() {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => addButtonToTabsMenu());
document.addEventListener('DOMContentLoaded', () => addDivToForm());
} else {
addButtonToTabsMenu();
addDivToForm();
}
}

// Add button to form - retry if form not found
function addButtonToTabsMenu() {
function addDivToForm() {
const form = document.querySelector('.container-fluid');
if (!form) {
setTimeout(() => addButtonToTabsMenu(), retryInterval);
setTimeout(() => addDivToForm(), retryInterval);
return;
}

if (document.getElementById(buttonId)) return;

const newDiv = createFormFillerElements();
form.insertBefore(newDiv, form.firstChild);
form.insertBefore(newDiv.mainDiv, form.firstChild);

setTimeout(() => newDiv.input.focus(), 0);
}

// Main div element
function createFormFillerElements() {
const newDiv = document.createElement('div');
newDiv.id = buttonId;
newDiv.style.cssText = 'display: flex; gap: 4px;';
const mainDiv = document.createElement('div');
mainDiv.style.cssText = 'display: flex; flex-direction: column; gap: 2px;';
mainDiv.id = buttonId;

const flexDiv = document.createElement('div');
flexDiv.style.cssText = 'display: flex; gap: 6px;';

const divider = document.createElement('div');
divider.style.cssText = 'width: 100%; height: 1px; background-color: #dadada; margin-top: 10px; margin-bottom: 20px;';

const label = createLabel();
const input = createInput();
const button = createButton();

newDiv.appendChild(input);
newDiv.appendChild(button);
mainDiv.appendChild(label);
mainDiv.append(flexDiv);
flexDiv.appendChild(input);
flexDiv.appendChild(button);
mainDiv.appendChild(divider);

return { mainDiv, input };
}

return newDiv;
// Label element
function createLabel() {
const label = document.createElement('p');
label.textContent = 'Job Listing URL';
label.style.cssText = 'font: 16px "Public Sans", sans-serif; font-weight: 500; margin-bottom: 6px;';
return label;
}

// Input element
function createInput() {
const input = document.createElement('input');
input.placeholder = 'Enter a seek.com.au job listing URL to auto fill the form below';
input.placeholder = 'Enter a Seek, Jora, or Indeed job listing URL';
input.style.cssText = `
background-color: #fff;
border: 1px solid #ccc;
Expand Down

0 comments on commit 5e29ad0

Please sign in to comment.