Linkedin Connect

Connect every possible connect with your msg

目前為 2020-02-06 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Linkedin Connect
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Connect every possible connect with your msg
// @match        https://www.linkedin.com/search/results/people/*
// @grant        none

// ==/UserScript==
const msg = "Hi, I’m Xinyi Tao, a Master’s student at Carnegie Mellon University. We are going to build a mobile app that makes the hiring process more efficient. Do you mind taking a quick survey so we can learn more about the hiring process? Thank you!\nThe survey link: https://forms.gle/4zVcTwNzY1EQ2wJc6"

const styles = `
.fixedElement {
background-color: white;
position:fixed;
top:0;
right:0;
width:40vw;
z-index:100;
}
`;
const styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);

function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
window.addEventListener('load', async () => {
    await sleep(1000);
    const div = document.createElement("div");
    div.classList.add("fixedElement");
    document.body.appendChild(div);
    window.scrollTo(0, document.body.scrollHeight);
    await sleep(2000);
    const allButtons = document.querySelectorAll('button')
    const buttons = []
    for (const button of allButtons)
        if (button.innerText === 'Connect') buttons.push(button);
    while (buttons.length !== 0) {
        button = buttons.pop()
        const parent = button.parentNode.parentNode.parentNode
        console.log(parent.querySelector('a').href)
        let b = document.createElement("p");
        b.innerText = parent.querySelector('a').href;
        div.appendChild(b);
        button.click()
        await sleep(500);
        const addNoteButton = document.querySelector('[aria-label="Add a note"]');
        console.log(addNoteButton)
        addNoteButton.click()
        await sleep(500);
        const textareaMsg = document.querySelector("textarea")
        textareaMsg.value = msg
        var evt = document.createEvent("Events");
        evt.initEvent("change", true, true);
        textareaMsg.dispatchEvent(evt);
        await sleep(100)
        const doneButton = document.querySelector('[aria-label="Done"]');
        doneButton.click()
        await sleep(1000)
        console.log("first finished")

    }
}, false);