HabrEnhancer

Cached pages from closed habrahabr/geektimes posts

当前为 2014-10-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name HabrEnhancer
  3. // @namespace dotneter
  4. // @include http://habrahabr.ru/*
  5. // @include http://geektimes.ru/*
  6. // @version 1.3
  7. // @description Cached pages from closed habrahabr/geektimes posts
  8. // ==/UserScript==
  9.  
  10. var h1 = document.querySelector("h1");
  11. if (h1 && h1.innerHTML == "Доступ к публикации закрыт") {
  12. h1.innerHTML += "<br/><br/>";
  13. var link = "http://webcache.googleusercontent.com/search?q=cache:" + window.location;
  14. h1.innerHTML += " <a href='" + link + "'>[Google Cache]</a>";
  15. var link = window.location.toString();
  16. link = link.replace(/(habrahabr.ru\/post\/)(\d+)\//, 'savepearlharbor.com/?p=$2');
  17. link = link.replace(/(geektimes.ru\/post\/)(\d+)\//, 'savepearlharbor.com/?p=$2');
  18. h1.innerHTML += " <a href='" + link + "'>[SavePearlHarbor]</a>";
  19. var link = window.location.toString();
  20. link = link.replace(/(habrahabr.ru\/post\/)(\d+)\//, 'sohabr.ru/post/$2/');
  21. link = link.replace(/(geektimes.ru\/post\/)(\d+)\//, 'sohabr.ru/post/$2/');
  22. h1.innerHTML += " <a href='" + link + "'>[SoHabr]</a>";
  23. } else {
  24. // быстрый доступ к трекеру
  25. $('a.logo[href="http://habrahabr.ru/feed/habred/"]').attr('href', 'http://habrahabr.ru/tracker/');
  26. }