Greasy Fork

Greasy Fork is available in English.

LinkedIn Assessement Hyperlinker

A light weight script to convert LinkedIn assessment questions into a clickable hyperlink to help you pass.

当前为 2020-10-05 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         LinkedIn Assessement Hyperlinker
// @namespace    https://www.linkedin.com/skill-assessments/*/quiz/*
// @version      1.04
// @description  A light weight script to convert LinkedIn assessment questions into a clickable hyperlink to help you pass.
// @author       JustSomeGuy
// @include      https://www.linkedin.com/skill-assessments/*/quiz/*
// @grant        none
// ==/UserScript==


var buttonElement = document.getElementsByClassName("sa-assessment-quiz__primary-action")[0];

// offset for page load
setTimeout(function() {
    convertQuestionToHyperLink();
}, 200);

function convertQuestionToHyperLink() {
    // get element containing question
    var questionElement = document.getElementById("assessment-a11y-title");
    // get question text
    var questionText = document.getElementsByClassName("sa-assessment-quiz__multi-line")[0]
    //get name of assessment
    var title = document.getElementsByClassName("mt1")[0].innerHTML;
    // remove "assessment" from string
    title = title.replace("Assessment", "");
    // remove leading/trailing spaces
    title = title.trim();

    // extract question
    var question = document.querySelectorAll("#assessment-a11y-title span")[2].innerHTML;
    // remove LinkedIn formatting
    question = question.replace('<span class="t-mono">','');
    question = question.replace('</span>','');
    // set search URL
    var url = "https://google.com/search?q="+title+' '+question.split(' ').join('+');

    // direct changes to the question breaks the process
    // create container for hyperlinked question
    var newquestionElement = document.createElement("span");
    // create hyperlink
    var a = document.createElement("a");
    // attach question to new container
    var newquestionText = document.createTextNode(question);
    // check to see if questionSpan id exists
    var questionSpan = document.getElementById("questionSpan");

    // set href
    a.href = url;
    // set target
    a.target = '_blank';

    // hide existing question container
    questionText.style.display = 'none';

    // attach new container with clickable hyperlink
    newquestionElement.appendChild(a).appendChild(newquestionText);
    // set id of new container
    newquestionElement.id = "questionSpan";

    // remove questionSpan element if it exists
    if (typeof(questionSpan) != 'undefined' && questionSpan !== null) {
        questionSpan.remove();
    }
    // add questionSpan element before answers element
    questionElement.insertBefore(newquestionElement, questionElement.childNodes[0]);
}

// update question and hyperlink when next button is clicked
buttonElement.addEventListener('click', function(){
    setTimeout(function() {
        convertQuestionToHyperLink();
    }, 500);
}, false);