-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93e25d2
commit ab101f1
Showing
10 changed files
with
129 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
job-app-sheetifier.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | ||
}); | ||
}; |