habr.com

Cached pages from closed habrahabr/geektimes posts.

  1. // ==UserScript==
  2. // @name habr.com
  3. // @include https://habr.com/*
  4. // @version 5.2
  5. // @description Cached pages from closed habrahabr/geektimes posts.
  6. // @description Remove all unnecessary blocks from page.
  7. // @grant none
  8. // @namespace https://habrahabr.ru/
  9. // ==/UserScript==
  10.  
  11. var h1 = document.querySelector("h1");
  12. if (h1 && h1.innerHTML == "Доступ к публикации закрыт") {
  13. h1.innerHTML += "<br/><br/>";
  14. var link = "http://webcache.googleusercontent.com/search?q=cache:" + window.location;
  15. h1.innerHTML += " <a href='" + link + "'>[Google Cache]</a>";
  16. var link = window.location.toString();
  17. link = link.replace(/(habr.com\/post\/)(\d+)\//, 'savepearlharbor.com/?p=$2');
  18. h1.innerHTML += " <a href='" + link + "'>[SavePearlHarbor]</a>";
  19. var link = window.location.toString();
  20. link = link.replace(/(habr.com\/post\/)(\d+)\//, 'sohabr.ru/post/$2/');
  21. h1.innerHTML += " <a href='" + link + "'>[SoHabr]</a>";
  22. } else {
  23. // быстрый доступ к трекеру
  24. $('a.logo[href="https://habr.com/ru/feed/"]').attr('href', 'https://habr.com/ru/tracker/');
  25. }
  26.  
  27. function GM_addStyle(css) {
  28. var head, style;
  29. head = document.getElementsByTagName('head')[0];
  30. if (!head) { return; }
  31. style = document.createElement('style');
  32. style.type = 'text/css';
  33. style.innerHTML = css;
  34. head.appendChild(style);
  35. }
  36.  
  37. GM_addStyle('.sidebar_content-area {display:none !important;}');
  38. GM_addStyle('.content_left {padding-right: 0px !important;}');