baptx

freelancer_country_filter.user

Jun 16th, 2020
1,412
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       freelancer.com country filter
  3. // @namespace https://drawcode.eu/
  4. // @include  https://www.freelancer.com/projects/*
  5. // @version  1
  6. // @grant    none
  7. // ==/UserScript==
  8.  
  9. /*
  10. // script to run in web console (e.g. in a separate Firefox profile to avoid new tab focus and tabs overflow)
  11.  
  12. var links = document.getElementsByClassName("JobSearchCard-primary-heading");
  13. var length = links.length;
  14. var i = -1;
  15. (function searchJobs() {
  16.     ++i;
  17.     if (i < length) {
  18.         if (links[i].children.length > 2) { // "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)
  19.             window.open(links[i].firstElementChild.href);
  20.             setTimeout(function(){searchJobs();}, 5000); // open new URL every 5 seconds (could be changed without breaking the script)
  21.         }
  22.         else {
  23.             searchJobs();
  24.         }
  25.     }
  26. })();
  27. */
  28.  
  29. var found = false;
  30. var targetNode = document.getElementsByTagName("app-root")[0];
  31. var config = {childList: true, subtree: true};
  32.  
  33. var callback = function(mutationsList, observer) {
  34.     for (var i = 0; found != true; ++i) {
  35.         if (mutationsList[i].addedNodes[0].nodeName == "FL-CARD") {
  36.             // only search country flag if we got a correct node name
  37.             var flag = document.getElementsByClassName("FlagImage")[0];
  38.             if (flag) {
  39.                 found = true;
  40.                 observer.disconnect();
  41.                
  42.                 var country = flag.title;
  43.                 // add or remove country codes as needed
  44.                 if (country != "gb" && // GB is used instead of UK
  45.                     country != "ie" &&
  46.                     country != "fr" &&
  47.                     country != "de" &&
  48.                     country != "ch" &&
  49.                     country != "es" &&
  50.                     country != "pt" &&
  51.                     country != "it" &&
  52.                     country != "be" &&
  53.                     country != "lu" &&
  54.                     country != "nl" &&
  55.                     country != "dk" &&
  56.                     country != "at" &&
  57.                     country != "se" &&
  58.                     country != "fi" &&
  59.                     country != "no" &&
  60.                     country != "is") {
  61.                     window.close();
  62.                 }
  63.             }
  64.         }
  65.     }
  66. };
  67.  
  68. var observer = new MutationObserver(callback);
  69. observer.observe(targetNode, config);
RAW Paste Data