Virtualmanager.com - Open all on free transfer to training page

Open all on free transfer to training page

  1. // ==UserScript==
  2. // @name Virtualmanager.com - Open all on free transfer to training page
  3. // @namespace https://greasyfork.org/en/users/884999-l%C3%A6ge-manden
  4. // @version 0.2
  5. // @description Open all on free transfer to training page
  6. // @author VeryDoc
  7. // @match https://www.virtualmanager.com/free_transfer_listings?*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=virtualmanager.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. let OpenAllButton = document.createElement('button');
  17. OpenAllButton.className = 'button';
  18. OpenAllButton.innerText = 'Open all';
  19. OpenAllButton.onclick = function () { OpenAll(); };
  20.  
  21. let OpenAllButtonAutoClose = document.createElement('button');
  22. OpenAllButtonAutoClose.className = 'button';
  23. OpenAllButtonAutoClose.innerText = 'Open all (auto close)';
  24. OpenAllButtonAutoClose.onclick = function () { OpenAllAutoClose(); };
  25.  
  26. var attachbox = document.getElementsByClassName('search')[0];
  27.  
  28. attachbox.appendChild(OpenAllButton);
  29. attachbox.appendChild(OpenAllButtonAutoClose);
  30.  
  31. function OpenAll() {
  32. var photos = document.getElementsByClassName('photo');
  33. var x = 100;
  34. for (let photo of photos) {
  35. setTimeout(openWindow, x, photo.href + "/training");
  36. x += 100;
  37. }
  38. }
  39.  
  40. function OpenAllAutoClose() {
  41. var photos = document.getElementsByClassName('photo');
  42. var x = 100;
  43. for (let photo of photos) {
  44. setTimeout(openWindow, x, photo.href + "/training?auto=true");
  45. x += 100;
  46. }
  47. }
  48.  
  49. function openWindow(s){
  50. // console.log(s);
  51. window.open(s, "_blank");
  52. }
  53. })();