Block sites

Block sites (such as Baidu, etc.) You can edit the block list in the script.

  1. // ==UserScript==
  2. // @name Block sites
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Block sites (such as Baidu, etc.) You can edit the block list in the script.
  6. // @author Laphy
  7. // @match http*://www.baidu.com/
  8. // @match http*://weibo.com/*
  9. // @match http*://feedly.com/*
  10. // @match http*://twitter.com/*
  11. // @match http://www.newsmth.net/*
  12. // @grant GM_addStyle
  13. // @run-at document-start
  14. // @require http://code.jquery.com/jquery-2.2.4.js
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19. var fullBlock = true;
  20. if(fullBlock)
  21. {
  22. window.stop();
  23. //not works, since the reloading will also be blocked.
  24. /*
  25. document.body = document.createElement("body");
  26. $('body').html(`<div id="NewContent">Connected. <a href='${document.URL}'>Restore</a></div>`);
  27. */
  28. return;
  29. }
  30.  
  31. $("body").css("visibility","hidden");
  32. $(document).ready(function() {
  33. var oldBody = $('body').html();
  34. $('body').html('<div id="NewContent">Connected. <a href="javascript:void(0)">Restore</a></div>');
  35. $("body").css("visibility","visible");
  36. GM_addStyle(`#NewContent {
  37. height: 300px;
  38. margin: 50px;
  39. padding: 50px;
  40. font-size:20pt;
  41. text-align:center;
  42. }`);
  43.  
  44. $("body a").click(function() {
  45. $('body').html(oldBody);
  46. });
  47. });
  48.  
  49. })();