Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-cahill committed Oct 29, 2024
1 parent 93e25d2 commit ab101f1
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
job-app-sheetifier.zip
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# job-application-sheetifier

A Chrome plugin to automate adding jobs that I've applied to on LinkedIn to a Google Sheet, because five extra clicks per job is way less fun than writing JavaScript

##### Attribution

* Rocket ship icons downloaded from [Freepik](https://www.flaticon.com/free-icons/rocket)
Binary file added icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<html>
<head>
<title>Job Application Sheetifier</title>
<style>
button {
padding: 10px;
background-color: #0F9D58;
display: inline-block;
}
</style>
<script type="text/javascript" src="setup.js"></script>
</head>
<body>
<input id="spreadsheetId" type="text" placeholder="Spreadsheet ID">
<button id="saveSpreadsheetId">Save spreadsheet ID</button>
</body>
</html>
30 changes: 30 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "job-app-sheetifier",
"description": "add jobs to a google sheet in order to track job applications",
"version": "1.0",
"manifest_version": 3,
"action": {},
"permissions": [
"activeTab",
"identity",
"storage"
],
"background": {
"service_worker": "service-worker.js"
},
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqKLCSWl2T1czfKEhCy6vnIS7ns1xcO3JUHckpHGKUc0qUY8flf1T3loG2KDhvf+Cu8hYKK2FbAmMPdtVobQbld/G2X0Xb683oqPhcMXeiVy14BtejZtgXWqKNFosEaZliD9PgmNWgVoZ+A3C4nfdgxHj93ZGiSEzSsJ8Cx2YHZQlsqExJSGEeT9WDdoOuu4hFfDxXAjP0CCSIKR2E6BNDf19GGXSPWeZUISJqcvpJ8GhmxBXneewSMtegg/963y0DCmMf5KIIz5RtWLa1Y1CfFUsNaOTAFvY/JX7w/nW+D+mHEmNY2lPweDWECokV5bphf9L1rRwZz//0kaBQMSM6QIDAQAB",
"oauth2": {
"client_id": "276765973735-pqg26v7nve74rg0t2pdafen5ep41bn0c.apps.googleusercontent.com",
"scopes": [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile",
"https://www.googleapis.com/auth/spreadsheets"
]
},
"icons": {
"16": "icons/16x16.png",
"32": "icons/32x32.png",
"48": "icons/48x48.png",
"128": "icons/128x128.png"
}
}
68 changes: 68 additions & 0 deletions service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
const getNextEmptyRow = async (googleAuthToken, spreadsheetId) => {
const requestOptions = {
method: 'GET',
headers: {
Authorization: `Bearer ${googleAuthToken}`,
},
};

const response = await fetch(`https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/Sheet1!A1:A1000`, requestOptions);
const responseJson = await response.json();
return responseJson.values.length + 1;
};

const postNewRowData = async (googleAuthToken, rowData) => {
const spreadsheetId = rowData.spreadsheetId;
const spreadsheetRange = `Sheet1!A${rowData.nextEmptyRow}:H${rowData.nextEmptyRow}`;
const requestOptions = {
method: 'PUT',
headers: {
Authorization: `Bearer ${googleAuthToken}`,
'Content-Type': 'application/json'
},
contentType: 'json',
body: JSON.stringify({
range: spreadsheetRange,
majorDimension: 'ROWS',
values: [ [ rowData.companyName, '', rowData.date, '', '', '', '', rowData.url ] ]
})
};

await fetch(`https://sheets.googleapis.com/v4/spreadsheets/${spreadsheetId}/values/${spreadsheetRange}?valueInputOption=USER_ENTERED`, requestOptions);
};

const parseNameFromLinkedIn = (pageTitle) => {
return pageTitle.split(' | ')[1];
};

const sanitizeLinkedInUrl = (url) => { //
const linkedInUrlRegex = new RegExp('^https://www\.linkedin\.com/jobs/view/\\d+', 'gm');
return linkedInUrlRegex.exec(url)[0];
};

chrome.action.onClicked.addListener(tab => {
chrome.storage.local.get(['spreadsheetId'], (storageItems) => {
const spreadsheetId = storageItems.spreadsheetId;
if (!spreadsheetId) {
chrome.tabs.create({ url: 'index.html' });
} else {
chrome.identity.getAuthToken({ interactive: true }, (googleAuthToken) => {
chrome.tabs.query({ active: true, currentWindow: true }, async (tabs) => {
const activeTab = tabs[0];
const nextEmptyRow = await getNextEmptyRow(googleAuthToken, spreadsheetId);
const currentDate = new Date();
const companyName = parseNameFromLinkedIn(activeTab.title);
const postingUrl = sanitizeLinkedInUrl(activeTab.url);
const rowData = {
companyName,
date: `${currentDate.getMonth() + 1}/${currentDate.getDate()}`,
url: postingUrl,
nextEmptyRow,
spreadsheetId
};
await postNewRowData(googleAuthToken, rowData);
});
});
}
});
});
6 changes: 6 additions & 0 deletions setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
window.onload = () => {
document.querySelector('#saveSpreadsheetId').addEventListener('click', async () => {
const spreadsheetId = document.getElementById('spreadsheetId').value;
await chrome.storage.local.set({ spreadsheetId });
});
};

0 comments on commit ab101f1

Please sign in to comment.