v2ex-ignore-topic-home

Ignore v2ex topics on homepage

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        v2ex-ignore-topic-home
// @namespace   http://github.com/leoleozhu
// @description Ignore v2ex topics on homepage
// @include	*://*.v2ex.com/
// @include	*://v2ex.com/
// @include	*://*.v2ex.com/?tab=*
// @include	*://v2ex.com/?tab=*
// @include	*://*.v2ex.com/go/*
// @include	*://v2ex.com/go/*
// @version     0.1.2
// ==/UserScript==

var w = unsafeWindow;
var $ = w.$;

String.prototype.format = String.prototype.f = function() {
    var s = this,
        i = arguments.length;

    while (i--) {
        s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
    }
    return s;
};

$(function(){
    $('.cell').each(function()
      {
          var cell = $(this);

          var ignore = $('<a href="#" style="float:right">忽略主题</a>');

          ignore.click(function(){
              var t = cell.find('.item_title a,.item_hot_topic_title a').attr('href');
              console.log('ignoring '+t);
              $.get(t).done(function(html){
                  var m = /\/ignore\/topic\/\d+\?once=\d+/.exec(html)
                  if(m)
                  {
                      $.get(m[0]).done(function(){cell.remove();});
                  }
              });

              cell.html('<p>ignoring...</p>');
              return false;
          });

          var tool = cell.find('td[width=auto]');
          tool.append(ignore);

     });
});