Skip to content

Instantly share code, notes, and snippets.

Last active July 1, 2020 13:16
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save baptx/198697d2b38157c1b2474f1c13658f03 to your computer and use it in GitHub Desktop. country filter
// ==UserScript==
// @name country filter
// @namespace
// @include*
// @version 1
// @grant none
// ==/UserScript==
// Commented script needs to run in web console on a job search page (e.g. in a separate Firefox profile to avoid new tab focus and tabs overflow)
// You need to be logged in because the logged out page is different and displays less jobs
var links = document.getElementsByClassName("JobSearchCard-primary-heading");
var length = links.length;
var i = -1;
(function searchJobs() {
if (i < length) {
if (links[i].children.length > 2) { // can decrease spam by only opening job offers with verified payment method (remove the if condition and else block if you want to see these jobs)[i].firstElementChild.href);
setTimeout(function(){searchJobs();}, 5000); // open new URL every 5 seconds (could be changed without breaking the script)
else {
// Script to use with a browser addon like Greasemonkey, to run after page load when opening a new job
// Page load is slow because the website DOM is created on the client-side with JavaScript and AJAX
// The script could be faster by using the website API directly but it could be flagged as a bot
// add or remove country codes as needed (GB is used instead of UK)
var countries = ["gb","ie","fr","de","ch","es","pt","it","be","lu","nl","dk","at","se","fi","no","is"];
var found = false;
var targetNode = document.getElementsByTagName("app-root")[0];
var config = {childList: true, subtree: true};
var callback = function(mutationsList, observer) {
for (var i = 0; found != true; ++i) {
if (mutationsList[i].addedNodes[0].nodeName == "FL-CARD") {
// only search country flag if we got a correct node name
var flag = document.getElementsByClassName("FlagImage")[0];
if (flag) {
found = true;
if (!countries.includes(flag.title)) {
var observer = new MutationObserver(callback);
observer.observe(targetNode, config);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment