[Obsolete] xHamster Auto Old Design

Reverts to Old Xhamster Design and keeps it that way

  1. // ==UserScript==
  2. // @name [Obsolete] xHamster Auto Old Design
  3. // @namespace https://greasyfork.org/en/scripts/370063-xhamster-auto-old-design
  4. // @version 1.0.3
  5. // @description Reverts to Old Xhamster Design and keeps it that way
  6. // @author Phlegomatic
  7. // @match https://xhamster.com/*
  8. // @include https://*.xhamster.com/*
  9. // @grant none
  10. // @run-at document-start
  11. // ==/UserScript==
  12.  
  13. var currentLocation = window.location;
  14. var xOld = "x_odvkey";
  15. var xNew = "x_ndvkey";
  16.  
  17. checkCookie(xNew);
  18.  
  19. function checkCookie(cname) {
  20. var c = document.cookie.match(new RegExp('(^| )' + cname + '=([^;]+)'));
  21. if (c) {
  22. // Running New Version.
  23. xSwitch();
  24. } else {
  25. // Running Old Version.
  26. setCookie(xOld,getCookie(xOld),5*365); // Set the cookie to not expire untill 5 years from now
  27. }
  28. }
  29.  
  30. function getCookie(cname) {
  31. var c = document.cookie.match(new RegExp('(^| )' + cname + '=([^;]+)'));
  32. if (c) return c[2];
  33. }
  34.  
  35. function setCookie(cname, cvalue, exdays) {
  36. var d = new Date();
  37. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  38. var expires = "expires="+d.toUTCString();
  39. document.cookie = cname + "=" + cvalue + ";" + expires + ";domain=.xhamster.com;path=/";
  40. }
  41.  
  42. function xSwitch() {
  43. // Switch Version
  44. window.location = "https://xhamster.com/switch";
  45. setTimeout(function(){window.location = currentLocation}, 500);
  46. }
  47.  
  48.  
  49.  
  50.  
  51.