forked from dubioustarantula/PandaMarklet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookmarklet.js
57 lines (50 loc) · 1.89 KB
/
bookmarklet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(function(){
var data = [];
var dataObj = {};
var site = window.location.origin;
var pathname = window.location.pathname;
var fillDataObj = function(){
for( var i = 0; i < descriptions.length; i++ ){
dataObj[descriptions[i]] = data[i];
}
console.log(dataObj);
};
var sendData = function(){
var http = new XMLHttpRequest();
var url = 'https://httpbin.org/post';
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/json');
http.send( JSON.stringify(dataObj) );
alert('Job saved');
};
if( site + pathname.slice(0,6) === 'https://www.linkedin.com/jobs2'){
var descriptions = ['Origin URL','Job URL', 'Company', 'Job Title', 'Location', 'Day Posted', 'Apply Link', 'Experience', 'Job Function', 'Employment Type', 'Industry', 'Employer Job ID', 'Job ID'];
data.push( site );
data.push( pathname );
data.push( $('div.content:eq(0)').find('span:eq(0)').text() );
data.push( $('h1')[0].innerHTML );
data.push( $('div.content:eq(0)').find('span:eq(2)').text() );
data.push( $('div.content:eq(0)').find('.posted').text() );
data.push( $('#offsite-apply-button').attr('href') );
var otherDetails = $('.value');
for( var i = 0; i < otherDetails.length; i++ ){
data.push(otherDetails[i].innerHTML)
}
fillDataObj();
sendData();
} else if ( site + pathname.split('/')[2] === 'https://angel.cojobs' ){
var descriptions = ['Origin URL', 'Job URL', 'Company', 'Job Title', 'Location', 'Skills', 'Salary'];
var CompanyTitle = $('.join-title').text().split(' at ');
data.push( site );
data.push( pathname );
data.push( CompanyTitle[1] );
data.push( CompanyTitle[0] );
data.push( $('.locations').text() );
data.push( $('.skills').text() );
data.push( $('.salary').text() );
fillDataObj();
sendData();
} else {
alert('Not a Valid Job Post');
}
}());