Greasy Fork 还支持 简体中文。

Faucetcrypto miniLink Clicker

Sh.faucet.gold and Sh.faucetcrypto.com autocompletion

  1. // ==UserScript==
  2. // @name Faucetcrypto miniLink Clicker
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Sh.faucet.gold and Sh.faucetcrypto.com autocompletion
  6. // @author Kduytsch
  7. // @match https://faucetcrypto.com/claim/*
  8. // @match https://faucet.gold/*/*
  9. // @icon https://www.google.com/s2/favicons?domain=faucetcrypto.com
  10. // @note Please register with my referral link : https://faucetcrypto.com/ref/1380686
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. var timerCSS='#showTimerText';
  16. var continueCSS='#main-button';
  17. // var continueCSS='body > div.container.container-fluid > div:nth-child(7)';
  18. let observer = new MutationObserver(mutationRecords => {
  19. console.log(mutationRecords); // console.log(the changes)
  20. setTimeout(function() {
  21. clickOnCssLink(continueCSS);
  22. }, random(500,1000));
  23. });
  24.  
  25. function isVisible (element) {
  26. //start with initial element to check visibility and display
  27. var el = document.querySelector(element);
  28. //display and visibility vary per browser and must be sought in different ways depending on the browser
  29. var t1 = el.currentStyle ? el.currentStyle.visibility : getComputedStyle(el, null).visibility;
  30. var t2 = el.currentStyle ? el.currentStyle.display : getComputedStyle(el, null).display;
  31. //if either of these are true, then the element is not visible
  32. if (t1 === "hidden" || t2 === "none") {
  33. return false;
  34. }
  35. //This regex is used to scan the parent nodes all the way up to the body element
  36. while (!(/body/i).test(el)) {
  37. //get the next parent node
  38. el = el.parentNode;
  39. //grab the values, if available,
  40. t1 = el.currentStyle ? el.currentStyle.visibility : getComputedStyle(el, null).visibility;
  41. t2 = el.currentStyle ? el.currentStyle.display : getComputedStyle(el, null).display;
  42. if (t1 === "hidden" || t2 === "none") {
  43. return false;
  44. }
  45. }
  46. //if all scans are not successful, then the element is visible
  47. return true;
  48. }
  49. function random(min,max){
  50. return min + (max - min) * Math.random();
  51. }
  52. function clickOnCssLink(pCSSPathStr) {
  53. var elemFound = document.querySelector(pCSSPathStr);
  54. if (elemFound) {
  55. elemFound.click();
  56. console.log("clicked on "+ pCSSPathStr);
  57. } else {
  58. console.log('Element NOT FOUND for XPath:\n' + pCSSPathStr);
  59. }
  60. };
  61.  
  62.  
  63. setTimeout(function() {
  64. if (isVisible(timerCSS)) {
  65. clickOnCssLink(timerCSS);
  66. observer.observe(document.querySelector(continueCSS), {
  67. childList: true, // observe direct children
  68. subtree: true, // and lower descendants too
  69. attributes: true,
  70. characterDataOldValue: true // pass old data to callback
  71. });
  72. }
  73. }, random(1000,2000));
  74.  
  75. })();