Last active
August 29, 2015 14:23
-
-
Save Silverium/c443b8fb77a7f51b3c71 to your computer and use it in GitHub Desktop.
This greasemonkey script displays as discarded InfoJobs.net' offers that user is not interested anymore. It also adds a button of "Discard" next to the button of "Inscribe".
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @description Display as discarded InfoJobs.net' offers that user is not interested anymore. | |
// @description Add a button of "Discard" next to the button of "Inscribe". | |
// @include https://www.infojobs.net/* | |
// @name Discarded Infojobs' Offers | |
// @name:es-MX Ofertas de InfoJobs Descartadas | |
// @downloadURL https://gist.github.com/Silverium/c443b8fb77a7f51b3c71 | |
// @updateURL https://gist.github.com/Silverium/c443b8fb77a7f51b3c71 | |
// @namespace github.com/Silverium | |
// @author Soldeplata Saketos Candela | |
// @version 1 | |
// @releasedOn 24/06/2015 | |
// @grant none | |
// ==/UserScript== | |
//Data control. Only if elements exist, do the code | |
if (document.getElementById('candidate_application')) { | |
function discardJobs() { | |
//First, select the inscription button by ID | |
var applyForJobButton = document.getElementById('candidate_application'); | |
applyForJobButton.innerHTML = "Inscribirme!"; //Shortening the text | |
//Then add the custom button | |
var btn = document.createElement("A"); // Create an <a> element | |
btn.setAttribute("class", "btn btn-primary btn-medium pull-right"); // set button styling with twitter's bootstrap | |
btn.setAttribute("onclick", "javascript:launchBack(this);return false;"); //go back to previous index | |
btn.style.background = "darkred"; //change background color | |
//animating mouse over :) | |
btn.onmouseenter = function() { | |
mouseEnter() | |
}; | |
function mouseEnter() { | |
btn.style.background = "black"; | |
} | |
btn.onmouseleave = function() { | |
mouseLeave() | |
}; | |
function mouseLeave() { | |
btn.style.background = "darkred"; | |
} | |
var t = document.createTextNode("DESCARTAR"); // Create a text node | |
btn.appendChild(t); // Append the text to <a> button | |
applyForJobButton.parentNode.appendChild(btn); // Append <button> to "Inscribirme a esta oferta" button | |
} | |
discardJobs(); | |
} | |
//customize results by color: | |
if (document.getElementsByClassName("disabled")) { //do they exist? => do the code | |
function customizeGreen() { | |
//Already inscribed will be lightgreen | |
var checked = document.getElementsByClassName("disabled"); | |
for (i = 0; i < checked.length; i++) { | |
checked[i].style.backgroundColor = "lightgreen"; | |
} | |
} | |
customizeGreen(); | |
} | |
if (document.getElementsByClassName("result-list-title")) { //do they exist? => do the code | |
function customizeRed() { | |
var titleHeader = document.getElementsByClassName("result-list-title"); | |
for (j = 0; j < titleHeader.length; j++) { | |
if (titleHeader[j].tagName == "H2") { | |
var offerCont = document.createElement("A"); // Create an <a> element | |
var hijos = titleHeader[j].parentNode.childNodes; //set all elements inside the container as an array to move them | |
titleHeader[j].parentNode.appendChild(offerCont); //insert the <a> element into the container | |
var urlRef = titleHeader[j].childNodes[1].getAttribute("href"); //get the href value to later pass it to offerCont | |
offerCont.setAttribute("href", urlRef); //pass the href of the <a> element | |
offerCont.setAttribute("class", "redCustomized"); //insert custom class | |
while (hijos.length > 1) { | |
offerCont.appendChild(hijos[0]); //move all elements inside the <a> element | |
} | |
} | |
} | |
} | |
var estilo = document.createElement("STYLE"); //Create a <style> element | |
document.getElementById("ca").appendChild(estilo); //insert the stylesheet element | |
estilo.innerHTML = ".redCustomized a:visited{color: lightsalmon}"; //style with color visited links and custom class | |
customizeRed(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment