v2ex-ignore-topic-home

Ignore v2ex topics on homepage

  1. // ==UserScript==
  2. // @name v2ex-ignore-topic-home
  3. // @namespace http://github.com/leoleozhu
  4. // @description Ignore v2ex topics on homepage
  5. // @include *://*.v2ex.com/
  6. // @include *://v2ex.com/
  7. // @include *://*.v2ex.com/?tab=*
  8. // @include *://v2ex.com/?tab=*
  9. // @include *://*.v2ex.com/go/*
  10. // @include *://v2ex.com/go/*
  11. // @version 0.1.2
  12. // ==/UserScript==
  13.  
  14. var w = unsafeWindow;
  15. var $ = w.$;
  16.  
  17. String.prototype.format = String.prototype.f = function() {
  18. var s = this,
  19. i = arguments.length;
  20.  
  21. while (i--) {
  22. s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
  23. }
  24. return s;
  25. };
  26.  
  27. $(function(){
  28. $('.cell').each(function()
  29. {
  30. var cell = $(this);
  31.  
  32. var ignore = $('<a href="#" style="float:right">忽略主题</a>');
  33.  
  34. ignore.click(function(){
  35. var t = cell.find('.item_title a,.item_hot_topic_title a').attr('href');
  36. console.log('ignoring '+t);
  37. $.get(t).done(function(html){
  38. var m = /\/ignore\/topic\/\d+\?once=\d+/.exec(html)
  39. if(m)
  40. {
  41. $.get(m[0]).done(function(){cell.remove();});
  42. }
  43. });
  44.  
  45. cell.html('<p>ignoring...</p>');
  46. return false;
  47. });
  48.  
  49. var tool = cell.find('td[width=auto]');
  50. tool.append(ignore);
  51.  
  52. });
  53. });
  54.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址