Permalink
Browse files

Add mute.js

git-svn-id: http://svn.coderepos.org/share/websites/twicli@39083 d0d07461-0603-4401-acd4-de1884942a52
  • Loading branch information...
1 parent 55573ec commit db0f62f6595c2e9bb74133122d09d2aefe7061d1 @NeoCat committed Dec 15, 2011
Showing with 114 additions and 3 deletions.
  1. +1 −0 index.html
  2. +2 −1 index_en.html
  3. +89 −0 plugins/mute.js
  4. +18 −0 plugins/regexp.js
  5. +4 −2 twicli.js
View
@@ -120,6 +120,7 @@
<li><b>geomap.js</b> : ジオタグ(GeoLocation)が付加されたtweetで、マーカ(<img src="images/marker.png">)をクリックした際にGoogle Mapをインライン表示します。詳しくは<a href="http://d.hatena.ne.jp/NeoCat/20100722/1279741190">こちら</a>
<li><b>tweet_url_reply.js</b> : tweetへのリンクURLに内容を取得するボタン(<img src="images/jump.png">)を追加します。(created by <a href="http://twitter.com/edvakf">@edvakf</a>)
<li><b>related_results.js</b>: ▼に関連するツイートを表示するメニューを追加します。(created by <a href="http://twitter.com/tkawa">@tkawa</a>)
+<li><b>mute.js</b>: ▼に指定したユーザやハッシュタグを含むツイートを1時間非表示にする機能を追加します。
</ul><li>非標準プラグイン (デフォルトでは無効のもの)<ul>
<li><b>reply_favicon.js</b>: Re新着時にfavicon(IE,Safari以外)とタイトルを変更します。(created by <a href="http://twitter.com/edvakf">@edvakf</a>)
<li><b>sound.js</b>: TLやReの新着時にサウンドを鳴らします。
View
@@ -109,9 +109,10 @@
<li><b>shorten_url.js</b> : Typing a URL in the text area followed by three semicolons (;;;) makes a shortened URL. (created by <a href="http://twitter.com/edvakf">@edvakf</a>)
<li><b>geomap.js</b> : Display inline Google Map by clicking the marker (<img src="images/marker.png">) of tweets with GeoLocation.
<li><b>tweet_url_reply.js</b>: Add a button (<img src="images/jump.png">) to get the content to URL of a tweet. (created by <a href="http://twitter.com/edvakf">@edvakf</a>)
+<li><b>related_results.js</b>: Add a menu to show the related tweets into ▼ (created by <a href="http://twitter.com/tkawa">@tkawa</a>).
+<li><b>mute.js</b>: Add a menu to mute (hide) tweets with specified user or hashtag temporarily (1 hour) in ▼.
</ul><li>Non-default plugins<ul>
<li><b>reply_favicon.js</b>: Change favicon(not supported by IE and Safari) and the title when 'Re' is updated. (created by <a href="http://twitter.com/edvakf">@edvakf</a>)
-<li><b>related_results.js</b>: Add a menu to show the related tweets into ▼ (created by <a href="http://twitter.com/tkawa">@tkawa</a>).
<li><b>sound.js</b>: Play sound when 'TL'/'Re' is updated.
<li><b>insert_hashtag.js</b>: Append the hashtag to your tweets automatically while a tab for the hashtag is opened. (created by <a href="http://twitter.com/_wa_">@_wa_</a>)
<li><b>shortcutkey.js</b>: Enable operation by shortcut keys. (-><a href="https://github.com/NeoCat/twicli/wiki/Shortcutkeys">List of the shortcut keys</a>)
View
@@ -0,0 +1,89 @@
+langResources['Mute'] = ['ミュート','除去'];
+
+var mute_min = 60; // minutes for mute
+
+registerPlugin({
+ popup: function() {
+ if (!$('mute_menu')) return;
+ $('mute_menu').href = "javascript:mute_menu('"+popup_ele.id+"')";
+ },
+ popup_hide: function() {
+ var menu = $('mute_popup');
+ if (menu)
+ document.body.removeChild(menu);
+ }
+});
+
+function mute_menu(id) {
+ var ele = $(id);
+ var tw = !display_as_rt && ele.tw.retweeted_status || ele.tw;
+
+ var menu = document.createElement('div');
+ menu.id = 'mute_popup';
+ menu.className = 'popup_menu';
+ document.body.appendChild(menu);
+
+ menu.style.display = "block";
+ menu.style.top = popup_top + 'px';
+ menu.style.left = $('popup').style.left;
+ $('popup_hide').style.height = Math.max(document.body.scrollHeight, $("tw").offsetHeight+$("control").offsetHeight) + 'px';
+ $('popup_hide').style.display = "block";
+
+ var mute_menu_user = function(screen_name) {
+ screen_name = screen_name.replace(/^[@@]/, '');
+ var a = document.createElement('a');
+ a.innerHTML = _('Mute') + ': @'+screen_name;
+ a.href = 'javascript:mute_user("'+screen_name+'")';
+ menu.appendChild(a);
+ }
+ var mute_menu_hash = function(hash) {
+ hash = hash.replace(/^[##]/, '');
+ var a = document.createElement('a');
+ a.innerHTML = _('Mute') + ': #'+hash;
+ a.href = 'javascript:mute_hash("'+hash+'")';
+ menu.appendChild(a);
+ }
+
+ mute_menu_user(tw.user.screen_name);
+ for (var i = 0; i < ele.childNodes.length; i++) {
+ var st = ele.childNodes[i];
+ if (st.className && st.className.indexOf('status') >= 0) {
+ for (var j = 0; j < st.childNodes.length; j++) {
+ var target = st.childNodes[j];
+ if (target.className == 'mention') {
+ mute_menu_user(target.innerHTML);
+ }
+ else if (target.className == 'hashtag') {
+ mute_menu_hash(target.innerHTML);
+ }
+ }
+ break;
+ }
+ }
+}
+function mute_menu_hide() {
+ $('popup_hide').style.display = "none";
+ var menu = $('mute_popup');
+ if (menu)
+ document.body.removeChild(menu);
+}
+
+function mute_user(user) {
+ var limit = parseInt(new Date().getTime()/1000) + mute_min * 60;
+ setRegexp('m:^' + user + '$::1:' + limit +'\n' +
+ 'm::@' + user + ':1:' + limit + '\n' + pickup_regexp);
+ mute_menu_hide();
+}
+function mute_hash(hash) {
+ var limit = parseInt(new Date().getTime()/1000) + mute_min * 60;
+ setRegexp('m::#' + hash + ':1:' + limit + '\n' + pickup_regexp);
+ mute_menu_hide();
+}
+
+// Popup menu
+if ($('regexp_add_ID')) {
+ var a = document.createElement('a');
+ a.id = 'mute_menu';
+ a.innerHTML = _('Mute') + '... (1h)';
+ $('popup').insertBefore(a, $('regexp_add_ID').nextSibling)
+}
View
@@ -210,6 +210,24 @@ registerPlugin({
}
});
+function expireRegexp() {
+ var updated = false;
+ var list = pickup_regexp.split(/[\r\n]/);
+ var list2 = [];
+ var now = new Date().getTime() / 1000;
+ for (var id = 0; id < list.length; id++) {
+ var limit = parseInt(list[id].split(':')[4]);
+ console.log(limit);
+ if (isNaN(limit) || limit == 0 || limit > now)
+ list2.push(list[id]);
+ else
+ updated = true;
+ }
+ if (updated) setRegexp(list2.join("\n"));
+ setTimeout(expireRegexp, 60*1000);
+}
+expireRegexp();
+
// Popup menu
function addIDRegexp(user, id) {
setRegexp(user + ':^' + user + '$\n' + user + '::@' + user + '\n' + pickup_regexp);
View
@@ -294,7 +294,7 @@ var myid = null; // 自ユーザID
var last_user = null; // user TLに表示するユーザ名
var last_user_info = null; // user TLに表示するユーザ情報(TLから切替時のキャッシュ)
// 設定値
-var currentCookieVer = 15;
+var currentCookieVer = 16;
var cookieVer = parseInt(readCookie('ver')) || 0;
var updateInterval = (cookieVer>3) && parseInt(readCookie('update_interval')) || 60;
var pluginstr = (cookieVer>6) && readCookie('tw_plugins') || ' regexp.js\nlists.js\noutputz.js\nsearch.js\nfavotter.js\nfollowers.js\nshorten_url.js\nresolve_url.js';
@@ -307,6 +307,7 @@ if (cookieVer<12 && pluginstr.indexOf('tweet_url_reply.js')<0) pluginstr+="\ntwe
if (cookieVer<13) pluginstr+="\nrelated_results.js";
if (cookieVer<14) pluginstr+="\nembedsrc.js";
if (cookieVer<15) pluginstr = pluginstr.replace(/search2\.js[\r\n]+/,'');
+if (cookieVer<16) pluginstr+="\nmute.js";
pluginstr = pluginstr.substr(1);
var plugins = new Array;
var max_count = Math.min((cookieVer>3) && parseInt(readCookie('max_count')) || 50, 200);
@@ -701,6 +702,7 @@ function popup_menu(user, id, ele) {
}
// ポップアップメニューを非表示
function popup_hide() {
+ callPlugins("popup_hide");
$('popup').style.display = 'none';
$('userinfo_popup').style.display = 'none';
$('popup_hide').style.display = 'none';
@@ -849,7 +851,7 @@ function makeHTML(tw, no_name, pid, userdesc) {
return x+"<a target=\"_blank\" class=\"hashtag\" title=\"#"+s+"\" href=\"http://search.twitter.com/search?q="+encodeURIComponent("#"+s)+"\">"+h+s+"</a>";
}
if (u.indexOf('/') > 0) return "<a target=\"_blank\" href=\""+twitterURL+u+"\" onclick=\"return link(this);\">"+_+"</a>";
- return "<a href=\""+twitterURL+u+"\" onClick=\"switchUser('"+u+"'); return false;\" >"+_+"</a>";
+ return "<a href=\""+twitterURL+u+"\" class=\"mention\" onClick=\"switchUser('"+u+"'); return false;\" >"+_+"</a>";
}).replace(/\r?\n|\r/g, "<br>") + '</span>' +
//Retweet情報
' <span id="rtinfo-'+eid+'" class="rtinfo">' +

0 comments on commit db0f62f

Please sign in to comment.