Productivity Saver

Redirects people to video if someone goes to reddit between 9 AM and 6 PM (inclusive).

当前为 2015-11-21 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Productivity Saver
  3. // @description Redirects people to video if someone goes to reddit between 9 AM and 6 PM (inclusive).
  4. // @include https://*.reddit.com
  5. // @include https://*.reddit.com/*
  6. // @include https://www.youtube.com/*
  7. // @run-at document-start
  8. // @version 0.0.1.20151121092205
  9. // @namespace https://greasyfork.org/users/12417
  10. // ==/UserScript==
  11.  
  12. // This whole code is meant to block websites you apply to this script to from 9 AM to 6 PM, with 1 check per minute.
  13. // For any further inquiries, please tell me at scratch.mit.edu/users/iamunknown2 or reddit/u/iamunknowntwo
  14.  
  15. function check() // This function will set the hours variable (which will specify the hours in the day).
  16. {
  17. var date1 = new Date();
  18. var hours = date1.getHours();
  19. if (hours >= 8 && hours <= 17) // If hours are 8 AM to 7 PM (inclusive)
  20. {
  21. if (window.location.href != "https://www.youtube.com/watch?v=ZXsQAXx_ao0")
  22. {
  23. window.location.href = "https://www.youtube.com/watch?v=ZXsQAXx_ao0"; // Will play "JUST DO IT" Shia LaBeouf speech
  24. }
  25. }
  26. var comments = document.getElementById("watch-discussion");
  27. comments.parentNode.removeChild(comments); // Bye bye YouTube comments!
  28. }
  29. check() // Will check first time run.
  30. setTimeout(check(), 60000); // Checks above code per minute.