Skip to content

Commit

Permalink
implemented version 0.4 for new Linkedin layout
Browse files Browse the repository at this point in the history
  • Loading branch information
Kravalg committed Feb 16, 2017
1 parent 3437394 commit 7eba849
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
1 change: 0 additions & 1 deletion components/html/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<header>
<div class="center-block">
<h3 class="pull-left app-name">Linkedin <sup class="text-danger">boost</sup></h3>
<img src="/components/img/christmas_tree.png" class="pull-left">
<div class="clearfix"></div>
</div>
</header>
Expand Down
67 changes: 52 additions & 15 deletions components/js/content.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
const contactsNumOnOnePage = 15, numberOfRepeat = 5;

function isPageNewLinkedin () {
return window.location.href.indexOf('linkedin.com/mynetwork') + 1;
}

function sendMessageToBackground (obj) {
chrome.runtime.sendMessage(obj);
}
Expand All @@ -15,7 +19,7 @@ function addContacts(height, countOfPagesScrolled) {
} else {
sendRequest();
}
}, 1500);
}, 2000);
}

function scrollDown(height, countOfPagesScrolled){
Expand All @@ -27,18 +31,37 @@ function sendRequest(){
var contactsNum = 1;
var addedContacts = [];

eachContactsList(function() {
jQuery(this).click();
if (isPageNewLinkedin()) {
eachContactsList(function() {
jQuery(this).click();

addedContacts[contactsNum] = {
initials: jQuery(this).parents('.mn-person-card.pymk-card')
.find('.mn-person-info__name.mn-person-info--has-hover')
.text(),
title: jQuery(this).parents('.mn-person-card.pymk-card')
.find('.mn-person-info__occupation')
.text(),
img: jQuery(this).parents('.mn-person-card.pymk-card').find('.mn-person-info__picture.ember-view > img').attr('src'),
link: jQuery(this).parents('.mn-person-card.pymk-card').find('.mn-person-info__picture.ember-view').attr('href')
};

contactsNum++;
});
} else {
eachContactsList(function() {
jQuery(this).click();

addedContacts[contactsNum] = {
initials: jQuery(this).parents('.card-wrapper').find('.picture img').attr('alt'),
title: jQuery(this).parents('.card-wrapper').find('.headline > span').attr('title'),
img: jQuery(this).parents('.card-wrapper').find('.picture img').attr('src'),
link: jQuery(this).parents('.card-wrapper').find('.picture a').attr('href')
};
addedContacts[contactsNum] = {
initials: jQuery(this).parents('.card-wrapper').find('.picture img').attr('alt'),
title: jQuery(this).parents('.card-wrapper').find('.headline > span').attr('title'),
img: jQuery(this).parents('.card-wrapper').find('.picture img').attr('src'),
link: jQuery(this).parents('.card-wrapper').find('.picture a').attr('href')
};

contactsNum++;
});
contactsNum++;
});
}

sendMessageToBackground({
action: 'added_contacts',
Expand Down Expand Up @@ -75,7 +98,11 @@ function onRequest(request, sender, sendResponse) {
}

function eachContactsList(callback) {
jQuery.each( jQuery('.card-wrapper .bt-request-buffed'), callback);
if (isPageNewLinkedin()) {
jQuery.each( jQuery('.mn-person-card__person-btn-ext.button-secondary-medium'), callback);
} else {
jQuery.each( jQuery('.card-wrapper .bt-request-buffed'), callback);
}
}

function getInvitedNumber (filters) {
Expand All @@ -85,10 +112,20 @@ function getInvitedNumber (filters) {
var filter = filters[key];

eachContactsList(function() {
if (isSearchedInString(jQuery(this).parents('.card-wrapper').find('.headline > span').attr('title'), filter)) {
numberFoundContacts++;
if (isPageNewLinkedin()) {
if (isSearchedInString(jQuery(this).parents('.mn-person-card.pymk-card')
.find('.mn-person-info__occupation')
.text(), filter)) {
numberFoundContacts++;
} else {
jQuery(this).parents('.mn-person-card.pymk-card').remove();
}
} else {
jQuery(this).parents('.pymk-card').remove();
if (isSearchedInString(jQuery(this).parents('.card-wrapper').find('.headline > span').attr('title'), filter)) {
numberFoundContacts++;
} else {
jQuery(this).parents('.pymk-card').remove();
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion components/js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function isTabLinkedin (tab) {
}

function isTabLinkedinPymk (tab) {
return tab.url.indexOf('linkedin.com/people/pymk') + 1;
return (tab.url.indexOf('linkedin.com/people/pymk') + 1) || (tab.url.indexOf('linkedin.com/mynetwork') + 1);
}

function sendMessageForAddContacts (tab, contactsNumber, filters) {
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Linkedin Boost",
"description": "This Chrome extension helps you to add new contacts in the social network LinkedIn",
"version": "0.3",
"version": "0.4",
"default_locale": "en",
"icons": {
"128": "components/icon.png"
Expand All @@ -19,7 +19,7 @@
"storage"
],
"content_scripts": [{
"matches": ["*://www.linkedin.com/people/pymk/*", "*://www.linkedin.com/people/pymk?*"],
"matches": ["*://www.linkedin.com/people/pymk/*", "*://www.linkedin.com/people/pymk?*", "*://www.linkedin.com/mynetwork*"],
"js": ["bower_components/jquery/dist/jquery.min.js", "components/js/class.localstorage.js", "components/js/content.js"]
}]
}

0 comments on commit 7eba849

Please sign in to comment.