stayLoggedIn

Keeps you logged in on specific sites. (edit @match and @include to set your own sites)

  1. // ==UserScript==
  2. // @name stayLoggedIn
  3. // @author Than
  4. // @version 0.02
  5. // @description Keeps you logged in on specific sites. (edit @match and @include to set your own sites)
  6. // @match https://*.lithium.hosting:*/*
  7. // @match https://lithiumhosting.com/*
  8. // @include https://*.lithium.hosting:*/*
  9. // @include https://lithiumhosting.com/*
  10. // @connect lithiumhosting.com
  11. // @grant GM.xmlHttpRequest
  12. // @grant unsafeWindow
  13. // @grant GM_addStyle
  14. // @grant GM_setClipboard
  15. // @run-at document-end
  16. // @namespace https://greasyfork.org/users/288098
  17. // ==/UserScript==
  18.  
  19.  
  20. (function() {
  21. 'use strict';
  22. var gmFetch = function ({url, // Supply the URL you want to XHR
  23. method="GET", // default method
  24. data="", // post data, if needed
  25. headers="", // includ headers as json.
  26. anonymous=false, // true: no cookies will be included. false: default browser cookies will be included.
  27. simple=true, // true returns just the response body. false returns the full response object.
  28. onprogressCallback=false, // supply a function name for a callback
  29. responseType = "text",
  30. }) {
  31. return new Promise((resolve, reject) => {
  32. headers = ((method === "POST" && headers === "") ? {"Content-Type": "application/x-www-form-urlencoded"} : headers);
  33. // console.log(GM.xmlHttpRequest);
  34. GM.xmlHttpRequest({
  35. method: method,
  36. url: url,
  37. headers: headers,
  38. data: data,
  39. anonymous: anonymous,
  40. onload: (simple ? e => resolve(e.response) : e => resolve(e)),
  41. onprogress: (onprogressCallback ? function (response) { onprogressCallback(response) } : false),
  42. onerror: reject,
  43. ontimeout: reject,
  44. responseType:responseType,
  45. });
  46. });
  47. }
  48. sendPing(document.location.href);
  49. /*--------------------------------------------------------------------------------------------------------------------
  50. ------------------------------------------- General functions --------------------------------------------------
  51. --------------------------------------------------------------------------------------------------------------------*/
  52. async function sendPing(url){
  53. console.log("ping active...")
  54. setInterval(sendRequest, 400000);
  55. async function sendRequest(){
  56. var response = await gmFetch({url:url});
  57. console.log(response);
  58. document.body.click();
  59. (function(path){
  60. var item = document.querySelector(path);
  61. if (!item){
  62. document.body.appendChild(document.createTextNode('Error: '+path+' not found'));
  63. return;
  64. };
  65. item.click();
  66. item.dispatchEvent(new Event('resize', {bubbles: true}));
  67. })('body');
  68. }
  69. } // Also, run all of the above when the document loads initially, not just during mutations
  70. // Your code here...
  71. })();