habrahabr.ru

Cached pages from closed habrahabr/geektimes posts.

目前为 2017-03-09 提交的版本。查看 最新版本

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