Greasy Fork

Greasy Fork is available in English.

Linkedin Connect

Connect every possible user with your message

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Linkedin Connect
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Connect every possible user with your message
// @include     https://www.linkedin.com/search/results/people/*hiring*
// @include     https://www.linkedin.com/search/results/people/*Hiring*
// @grant        none

// ==/UserScript==




const msg = "Hi, I’m 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/NydUPcn8XzrSHoX2A"

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);

var div
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}
async function startConnect() {
    await sleep(1000);
    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) {
        const 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"]')?document.querySelector('[aria-label="Done"]'):document.querySelector('[aria-label="Send invitation"]');
        if (doneButton.disabled) {
            document.querySelector('[aria-label="Dismiss"]').click();
            await sleep(1000)
        }
        doneButton.click()
        await sleep(1000)
        console.log("first finished")

    }
    const previousButton = document.querySelector('[aria-label="Next"]');
    previousButton.click()
}
var pushState = history.pushState;
history.pushState = function () {
    pushState.apply(history, arguments);
    const re = new RegExp("https://www.linkedin.com/search/results/people/.*hiring.*")
    if (document.URL.toLowerCase().match(re))
        startConnect()
};
window.addEventListener('load', ()=>{
    div = document.createElement("div");
    div.classList.add("fixedElement");
    document.body.appendChild(div);
    startConnect()
}, false);