-
-
Save twinsant/4f872ca0600f45ff9d76fc160f1f86eb to your computer and use it in GitHub Desktop.
Upwork view helper.
This file contains hidden or 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== | |
| // @name Upwork tool | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author twinsant | |
| // @match https://www.upwork.com/nx/find-work/best-matches | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=upwork.com | |
| // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js | |
| // @require https://cdnjs.cloudflare.com/ajax/libs/jshashes/1.0.8/hashes.min.js | |
| // @grant GM_xmlhttpRequest | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| console.log("Countdown 10s..."); | |
| window.scroll({ | |
| top: 500, | |
| left: 0, | |
| behavior: 'smooth', | |
| }); | |
| setTimeout(()=>{ | |
| // Your code here... | |
| var jobs = []; | |
| $("div[data-test=job-tile-list]").children().each(function(item) { | |
| // console.log(item, $(this).text()); | |
| var title = $(this).find(".job-tile-title"); | |
| var href = title.find("a").attr("href"); | |
| var str = title.text(); | |
| var MD5 = new Hashes.MD5 | |
| var hash = MD5.hex(str) | |
| var job_type = $(this).find("strong[data-test='job-type']").text(); | |
| var budget = $(this).find("span[data-test='budget']").text().trim(); | |
| //console.log(job_type, budget); | |
| var price = 0; | |
| if (job_type == 'Fixed-price') { | |
| price = parseInt(budget.substring(1)); | |
| //console.log(price); | |
| } else { | |
| //console.log(job_type); | |
| const re = /Hourly: \$(\d+)/; | |
| const m = re.exec(job_type); | |
| if (m) { | |
| price = parseInt(m[1]); | |
| job_type = 'Hourly'; | |
| } | |
| } | |
| //console.log(`${hash} ${str} ${href}`); | |
| var job = { | |
| hash: hash, | |
| title: str.trim(), | |
| href: href, | |
| type: job_type, | |
| price: price | |
| }; | |
| jobs.push(job); | |
| }); | |
| GM_xmlhttpRequest({ | |
| method: "POST", | |
| headers: { | |
| 'Accept': 'application/json', | |
| "Content-Type": "application/json", | |
| "User-Agent": "TM" | |
| }, | |
| url: `http://127.0.0.1:3000/api/upwork`, | |
| data: JSON.stringify({jobs: jobs}), | |
| dataType: 'json', | |
| contentType: 'application/json', | |
| overrideMimeType: 'application/json', | |
| onload: function (response) { | |
| //console.log(`${JSON.parse(response.response)}`); | |
| console.log(response.status); | |
| } | |
| }); | |
| }, 5000); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment