
Ubuntu日本語フォーラム

ログインしていません。
現在は、Akregatorを利用しています。
とあるUbuntuのフォーラムで、参考にもならず、読むだけ時間の無駄である投稿者を見掛けるので、これをフィードリーダー側で排除できないかと思案しています。
トピック内の読みたく無い投稿者によるレスは、サイト側で対応していただけないと対処できなそうですが、トピック主の削除はフィーダー側で設定できるのではないか?と、探しています。
何か良い方法を知りませんか?
個別に対処可能なソフトを御紹介いただけても嬉しいですが、Aregatorを使って上記を対処できればもっと嬉しいです。
ソフト探しが主ではないので、個別にトピックを立てました。
こんなソフトが欲しい!知りませんか?
https://forums.ubuntulinux.jp/viewtopic.php?id=365
オフライン
方法としては"全文に対して検索をし、マッチしたものを除外する"という機能を使えれば出来そうです。
私の使っているLifereaでは検索フォルダというものを作り、プロパティで、
"幾つかを満足するもの"とし
本文-が次の内容を含まない-"投稿者: *****"
本文-が次の内容を含まない-"フォーラム: Off-Topics"
配信元のタイトル-が次の内容を含む-"Ubuntu日本語フォーラム"
で出来ているようです。
Aregatorでも出来るのでは?
オフライン
nimuさん
Lifereaの御紹介、ありがとうございます。
Aregatorでは、基本的な機能しか用意されていないので、そういった利用は全くできませんでした。
Lifereaは取得したフィードの検索や取得時にスクリプトを用いるといったカスタマイズが可能で、とても便利そうです。
nimuさんの方法に従い、Ubuntu日本語フォーラムでテストをしてみました。
ですが、1件も表示されません。
↓ここでつまづいているようで、この項目のみでも1件も表示されませんでした
配信元のタイトル-が次の内容を含む-"Ubuntu日本語フォーラム"
設定を行った箇所はフィードを登録して、検索フォルダを作っただけです。
他に設定しなければいけない項目がありますでしょうか?
オフライン
お探しのものとは違いますが,精神衛生上の観点から,Ubuntu日本語フォーラムの特定の投稿者のポストを非表示にする greasemonkey スクリプトを作成しました.
greasemonkey は karmic のレポジトリにもあります.
greasemonkey - firefox extension that enables customization of webpages with user scripts
各トピックのページの投稿本文と投稿者の名前を非表示にするスクリプトです.
配列 banned に非表示にしたい投稿者のIDを列挙します.
$ cat ubuntu-ja-hide-post.user.js
// ==UserScript==
// @name ubuntu-ja-hide-post
// @namespace http://localhost/
// @description Hack for Ubuntu Japanese Forum, Hide Posts by ID
// @include https://forums.ubuntulinux.jp/viewtopic.php*
// ==/UserScript==
(function(){
var banned = [9907, 11097];
var censored = '<span style="color:gray">censored</span>';
var posts = document.getElementById('punviewtopic');
for (var i = 0; i < banned.length; ++ i)
{
var xpath = '//a[@href="profile.php?id=' + banned[i] + '"]';
var nodes = document.evaluate(xpath, posts, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for(var j = 0, elem; elem = nodes.snapshotItem(j); ++ j)
{
for(var k = 0; k < 3; ++ k)
{
elem = elem.parentNode;
}
elem.innerHTML = censored;
elem.parentNode.nextSibling.nextSibling.innerHTML = censored;
}
}
})();トップページの最新の投稿へのリンクや各カテゴリでの投稿へのリンクを非表示にするスクリプトも作りました.
これらのスクリプトでは配列 banned には対象のユーザ名を列挙します.
$ cat ubuntu-ja-hide-last.user.js
// ==UserScript==
// @name ubuntu-ja-hide-last
// @namespace http://localhost/
// @description Hack for Ubuntu Japanese Forum, Hide the Last Post by Name
// @include https://forums.ubuntulinux.jp/index.php
// @include https://forums.ubuntulinux.jp/
// ==/UserScript==
(function(){
var banned = ['einundzwanzighundertsechs', 'kie'];
var censored = '<span style="color:gray">censored</span>';
var posts = document.getElementById('idx1');
for (var i = 0; i < banned.length; ++ i)
{
var xpath = '//td[@class="tcr"]/span[@class="byuser" and .="by ' + banned[i] + '"]';
var tcr = document.evaluate(xpath, posts, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for(var j = 0, elem; elem = tcr.snapshotItem(j); ++ j)
{
elem.parentNode.innerHTML = censored;
}
}
})();$ cat ubuntu-ja-hide-topic.user.js
// ==UserScript==
// @name ubuntu-ja-hide-topic
// @namespace http://localhost/
// @description Hack for Ubuntu Japanese Forum, Hide Topics by Name
// @include https://forums.ubuntulinux.jp/viewforum.php*
// ==/UserScript==
(function(){
var banned = ['einundzwanzighundertsechs', 'kie'];
var censored = '<span style="color:gray">censored</span>';
var topics = document.getElementById('vf');
function censor(xpath, byname)
{
var nodes = document.evaluate(xpath, topics, null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0, elem; elem = nodes.snapshotItem(i); ++ i)
{
if (elem.innerHTML === byname)
{
elem.parentNode.innerHTML = censored;
}
}
};
for (var i = 0; i < banned.length; ++ i)
{
var name = banned[i];
var byname = 'by ' + name;
censor('//td[@class="tcl"]//span[@class="byuser" and contains(.,"' + name + '")]', byname);
censor('//td[@class="tcr"]/span[@class="byuser" and contains(.,"' + name + '")]', byname);
}
})();上記サンプルの実験台としては 私 と,失礼ながら無断で Thread Starter の kie さんの id と御名前を使用しています.
kie さん,事後承諾となりますがお赦し下さい.
オフライン
このようなものは不要であるのが望むべきフォーラムの姿でしょう.
ですから,使いやすくするための改善(?)には抵抗があります.
しかし,コード保守のためのリファクタリングには「性」で抗えません.
#4 の greasemonkey スクリプトの機能を一つのスクリプトにまとめました.
配列 banned には対象のユーザ名を列挙します.
var banned = ['ユーザ名1', 'ユーザ名2', '…'];
下記コードには 私のユーザ名のみ を入れてあります.私の投稿を見たくない方はそのまま使って下さい.
$ cat ubuntu-ja-ban-users.user.js
// ==UserScript==
// @name ubuntu-ja-ban-users
// @namespace http://localhost/
// @description Hack for Ubuntu Japanese Forum, Hide some Users
// @include https://forums.ubuntulinux.jp/
// @include https://forums.ubuntulinux.jp/index.php
// @include https://forums.ubuntulinux.jp/viewforum.php*
// @include https://forums.ubuntulinux.jp/viewtopic.php*
// ==/UserScript==
(function(){
var banned = ['einundzwanzighundertsechs'];
var censored = '<span style="color:gray">censored</span>';
function foreach(id, inner, outer, proc)
{
for (var i = 0; i < banned.length; ++ i)
{
banned[i] = inner(banned[i]);
}
var nodes = document.evaluate(outer(banned.join(' or ')),
document.getElementById(id),
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < nodes.snapshotLength; ++ i)
{
proc(nodes.snapshotItem(i));
}
}
function enclose(prefix, suffix)
{
return function(x) { return prefix + x + suffix; };
}
function censor(x)
{
x.innerHTML = censored;
}
switch (location.pathname)
{
case '/':
case '/index.php':
foreach('idx1',
enclose('span="by ', '"'),
enclose('//td[@class="tcr" and span/@class="byuser" and ',
']'),
censor);
break;
case '/viewforum.php':
foreach('vf',
enclose('.="by' + String.fromCharCode(160), '"'),
enclose('//td[@class="tcl" or @class="tcr"]//span[@class="byuser" and ',
']/parent::*'),
censor);
break;
case '/viewtopic.php':
foreach('punviewtopic',
enclose('.//a="', '"'),
enclose('//div[@class="postleft"]/dl[', ']'),
function(x)
{
x.innerHTML = censored;
x.parentNode.nextSibling.nextSibling.innerHTML = censored;
});
break;
}
})();ともあれ XPath の勉強になりました.
次の機会には「Ubuntu 日本語フォーラム」の表示を使いやすくカスタマイズする,建設的なスクリプトに応用したいものです.
オフライン
仮令他のメンバによる引用の中であっても
対象者 による投稿:
まさにルサンチマンの顕れと言える卑屈な論理で他人の好意を曲解するような文章
は目に入れるに値しないとわかりました.
前言撤回して機能強化します.上記のような引用ボックスも非表示にします.
$ cat ubuntu-ja-ban-users.user.js
// ==UserScript==
// @name ubuntu-ja-ban-users
// @namespace http://localhost/
// @description Hack for Ubuntu Japanese Forum, Hide some Users
// @include https://forums.ubuntulinux.jp/
// @include https://forums.ubuntulinux.jp/index.php
// @include https://forums.ubuntulinux.jp/viewforum.php*
// @include https://forums.ubuntulinux.jp/viewtopic.php*
// ==/UserScript==
(function(){
var banned = ['einundzwanzighundertsechs'];
var censored = '<span style="color:gray">censored</span>';
var hideStarted = false;
function foreach(from, inner, outer, proc)
{
var a = [];
for (var i = 0; i < banned.length; ++ i)
{
a.push(inner(banned[i]));
}
var nodes = document.evaluate(outer(a.join(' or ')),
from,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
for (var i = 0; i < nodes.snapshotLength; ++ i)
{
proc(nodes.snapshotItem(i));
}
}
function enclose(prefix, suffix)
{
return function(x) { return prefix + x + suffix; };
}
function censor(x)
{
x.innerHTML = censored;
}
switch (location.pathname)
{
case '/':
case '/index.php':
foreach(document.getElementById('idx1'),
enclose('span="by ', '"'),
enclose('//td[@class="tcr" and span/@class="byuser" and (',
')]'),
censor);
break;
case '/viewforum.php':
var vf = document.getElementById('vf');
var nbsp = String.fromCharCode(160);
if (hideStarted)
{
foreach(vf,
enclose('span="by' + nbsp, '"'),
enclose('//td[@class="tcr" and span/@class="byuser" and (',
')]'),
censor);
foreach(vf,
enclose('td//span="by' + nbsp , '"'),
enclose('//tr[td/@class="tcl" and td//span/@class="byuser" and (',
')]'),
function(x)
{
x.innerHTML = '<td class="tcl"><div class="tclcon">' + censored + '</div></td><td class="tc2"></td><td class="tc3"></td><td class="tcr"></td>';
});
}
else
{
foreach(vf,
enclose('.="by' + nbsp, '"'),
enclose('//td[@class="tcl" or @class="tcr"]//span[@class="byuser" and (',
')]/parent::*'),
censor);
}
break;
case '/viewtopic.php':
var punviewtopic = document.getElementById('punviewtopic');
foreach(punviewtopic,
enclose('.//a="', '"'),
enclose('//div[@class="postleft"]/dl[', ']'),
function(x)
{
x.innerHTML = censored;
x.parentNode.nextSibling.nextSibling.innerHTML = censored;
});
foreach(punviewtopic,
enclose('h4="', ' による投稿:"'),
enclose('//blockquote/div[@class="incqbox" and (', ')]'),
censor);
break;
}
})();ただしこの版では
対象者さま による投稿:
だと検閲を逃れてしまいます.XPath 式で starts-with を使うとそれも引っ掛けられますが,
enclose('starts-with(h4,"', '")'),その場合は「対象者1192」等の名の他のユーザの引用も非表示になってしまいます.
ついでに #5 のスクリプトの XPath 式で,括弧を忘れていて検索が想定した手順になっていなかったのも修正しました.
オフライン
変換ミスです.意味がおかしくなってしまう.
他人の好意 → 他人の厚意
オフライン
einundzwanzighundertsechsさん
スクリプトありがとうございます。
Firefoxを使うことも多いので、greasemonkeyスクリプトは便利です。
Epiphanyでも使えるはずですが、今はgreasemonkeyが動かないのでしたっけ…?
トピック内の#6スクリプトを試してみました。
ステータスバー内のgreasemonkeyアイコンを右クリック
↓
新規ユーザースクリプト
↓
https://forums.ubuntulinux.jp/*
をアドレスで指定
↓
ubuntu-ja-ban-users
の名前を記入
としましたが、Ubuntu9.10、Firefox3.5.8で動作していないようです。
スクリプトの理解は足りていません。
本来の動作は
var banned = ['einundzwanzighundertsechs'];
の部分にある名前を変更すれば、該当者の名前とリンクが非表示になって…?(後よくわかりません)でしょうか。
通常見られるフォーラムのページと変わりが無いように見えています。
念のため
~/.mozilla/firefox/********.default/gm_scripts/ubuntu-ja-ban-users/ubuntu-ja-ban-users.user.js
をnautilusで "プログラムとして実行できる" とチェックしましたが、変化はありませんでした。
含めたり、含めなかったりして動作が変わりませんでしたが、文先頭のcatも必要でしょうか?
オフライン
kie さんへ,
お猿のアイコンはグレーアウトしてませんよね?
お猿のアイコンで右クリックで,スクリプト名にチェックが入っているのは確認できますか?
FireFox の ツール→エラーコンソールに何かエラーは出てませんか?
エラーコンソール右上の「消去」をクリックしてログを消し,フォーラムのページをリロードすると,スクリプトの実行エラーならば太字で何か出ます.
ちなみに,私の想定していたインストール手順は,
1. エディタを開いて,コードブロックの cat コマンド行を除く2行目以降をコピー&ペースト
2. 配列 banned の行を修正 /* 私が対象ならば不要 */
3. コードブロック1行目の cat コマンド行のファイル名 ….user.js で保存
4. ….user.js ファイルを greasemonkey が動いている FireFox にドラッグ&ドロップ,または,「ファイル→ファイルを開く」
5. 以降,配列 banned の行の修正は「ユーザスクリプトの管理」の「編集」ボタンを使う
です.greasemonkey の config.xml に設定が残っているので一旦アンインストールすると良いでしょう.
ついでに,私が現在試用(使用)中の版を貼り付けておきます.
実は,特定のトピックを対象に非表示にする greasemonkey スクリプトも作成していました.
対象者の文章を過って見てしまう確率を減らすため,その機能を取り込んで試用しています.
// さらに,まだ XPath 式 や document.evaluate について解ってなかったので修正.
各フォーラムのページ(viewforum.php?id=…)で対象者が立てたトピックを見つけたら,
- トピックの一覧から取り除きます.そのページ(viewforum.php)を見ている限り返事が投稿されたことも気づくことはないでしょう.
- トピックの ID を記録し,以降は該当のトピックのページを表示しません.例えば対象者以外のメンバがそのトピックに新規投稿すると,トップページの一覧に載りますが,リンクをクリックしても表示しません.内外のリンクやロケーションバーからの参照でも同様です.
- 記録したトピックの ID は prefs.js に記録されるので,リセットするには about:config を使います.
このスクリプトを使う場合,以前のスクリプトは無効化するか,「ユーザスクリプトの管理」からアンインストールしてください.
$ cat ubuntu-ja-censor.user.js
// ==UserScript==
// @name ubuntu-ja-censor
// @namespace http://localhost/
// @description Hack for Ubuntu Japanese Forum, Hide some Topics and Users
// @include https://forums.ubuntulinux.jp/
// @include https://forums.ubuntulinux.jp/index.php
// @include https://forums.ubuntulinux.jp/viewforum.php*
// @include https://forums.ubuntulinux.jp/viewtopic.php*
// ==/UserScript==
(function(){
var banned = ['einundzwanzighundertsechs'];
var censored = '<span style="color:gray">censored</span>';
var blocked = eval(GM_getValue('blocked', '[]'));
function getNodes(list, from, outer, inner)
{
if (list.length == 0) return { snapshotLength: 0 };
var a = [];
for (var i = 0; i < list.length; ++ i)
{
a.push(inner(list[i]));
}
return document.evaluate(outer(a.join(' or ')),
from,
null,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null);
}
function foreach(from, outer, inner, proc)
{
var nodes = getNodes(banned, from, outer, inner);
for (var i = 0; i < nodes.snapshotLength; ++ i)
{
proc(nodes.snapshotItem(i));
}
}
function enclose(prefix, suffix)
{
return function(x) { return prefix + x + suffix; };
}
function censor(x)
{
x.innerHTML = censored;
}
switch (location.pathname)
{
case '/':
case '/index.php':
foreach(document,
enclose('id("punindex")//td[@class="tcr" and span/@class="byuser" and (', ')]'),
enclose('span="by ', '"'),
censor);
break;
case '/viewforum.php':
var vf = document.getElementById('vf');
var nodes = getNodes(blocked,
vf,
enclose('.//tr[td/@class="tcl"][', ']'),
enclose('.//a/@href="viewtopic.php?id=','"'));
for (var i = 0; i < nodes.snapshotLength; ++ i)
{
var node = nodes.snapshotItem(i);
node.parentNode.removeChild(node);
}
var nbsp = String.fromCharCode(160);
foreach(vf,
enclose('.//td[@class="tcr" and span/@class="byuser" and (', ')]'),
enclose('span="by' + nbsp, '"'),
censor);
foreach(vf,
enclose('.//tr[td/@class="tcl" and td//span/@class="byuser" and (', ')]'),
enclose('td//span="by' + nbsp , '"'),
function(x)
{
var id = document.evaluate('.//div/a[1]/@href',
x,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue.value;
id = /\d+$/.exec(id)[0];
blocked.push(id);
GM_setValue('blocked', blocked.toSource());
x.parentNode.removeChild(x);
});
break;
case '/viewtopic.php':
var punviewtopic = document.getElementById('punviewtopic');
function isBlocked()
{
if (blocked.length > 0
&&
new RegExp('[?&]id=(' + blocked.join('|') + ')(&|$)')
.test(location.search)) return true;
var pagelink = document.evaluate('.//p[@class="pagelink conl"]',
punviewtopic,
null,
XPathResult.FIRST_ORDERED_NODE_TYPE,
null).singleNodeValue;
if (blocked.length > 0
&&
getNodes(blocked,
pagelink,
enclose('a[1][', ']'),
enclose('starts-with(@href,"viewtopic.php?id=','&p=")')).snapshotLength > 0) return true;
if (document.evaluate('count(a)',
pagelink,
null,
XPathResult.NUMBER_TYPE,
null).numberValue > 0) return false;
var starter = document.evaluate('.//div["blockpost rowodd firstpost"]//div[@class="postleft"]//strong[1]//text()',
punviewtopic,
null,
XPathResult.STRING_TYPE,
null).stringValue;
for (var i = 0; i < banned.length; ++ i)
{
if (starter === banned[i]) return true;
}
return false;
}
if (isBlocked())
{
document.title = 'Censored';
document.body.innerHTML = '<div style="text-align:center;margin-top:20pt;font-size:20pt;color:red;">Censored</div>';
setTimeout('history.back()', 1000);
break;
}
foreach(punviewtopic,
enclose('.//div[@class="postleft"]/dl[', ']'),
enclose('.//strong[1]//text()="', '"'),
function(x)
{
x.innerHTML = censored;
x.parentNode.nextSibling.nextSibling.innerHTML = censored;
});
foreach(punviewtopic,
enclose('.//blockquote/div[@class="incqbox" and (', ')]'),
enclose('h4="', ' による投稿:"'),
censor);
break;
}
})();オフライン
補足です.
einundzwanzighundertsechs による投稿:
2. 配列 banned の行を修正 /* 私が対象ならば不要 */
対象者の名に日本語が含まれている場合,スクリプトの文字コードを UTF-8 にします.
4. ….user.js ファイルを greasemonkey が動いている FireFox にドラッグ&ドロップ,または,「ファイル→ファイルを開く」
ここで,インストール確認のダイアログが開きます.こちらでも時折開かず,FireFox でコードが表示される事がありますが,もう一度ドラッグ&ドロップすると大抵の場合インストールできます.
オフライン
私がここに貼り付けたときのミスを疑い,#6, #9 のスクリプトをそのまま #9 の手順で再インストールしました.
このページをリロードしたら,どちらでも私の投稿が"検閲"されました.
此方も Ubuntu 9.10, FireFox 3.5.8 です.
greasemonkey 0.8.20100211.5 は Karmic の repository のものではなく,
FireFox のツール→アドオンからインストールしたものを使っています.
オフライン
お猿さんはグレーアウトしていなくて
右クリックでチェックが入っていて
エラーログはこちらで…
(私もgreasemonkyは、repositoryからではなく、Firefoxのwebにあるアドオンサイトから入手しました
そもそもrepositoryにある事をコメントによって知りました)
エラー: missing ; before statement
ソースファイル: file:///home/kie/.mozilla/firefox/********.default/gm_scripts/ubuntu-ja-ban-users/ubuntu-ja-ban-users.user.js
行: 1
警告: 'margin' の値をパース中にエラーが発生しました。 このスタイル宣言は無視されました。
ソースファイル: https://forums.ubuntulinux.jp/style/Ubuntu.css
行: 146
警告: 'padding' の値をパース中にエラーが発生しました。 このスタイル宣言は無視されました。
ソースファイル: https://forums.ubuntulinux.jp/style/Ubuntu.css
行: 147
警告: 'margin' の値をパース中にエラーが発生しました。 このスタイル宣言は無視されました。
ソースファイル: https://forums.ubuntulinux.jp/style/Ubuntu.css
行: 153
警告: 'padding' の値をパース中にエラーが発生しました。 このスタイル宣言は無視されました。
ソースファイル: https://forums.ubuntulinux.jp/style/Ubuntu.css
行: 154
と、チェックをした後に #9 の方法でアンインストールとインストールを行いました。
エラー: missing ; before statement
は吐き出さず、他の4つの警告が変わらず表示され
動作はしていない模様…なぜだろうと眺めていると恥ずかしい凡ミスを発見しました。
凡ミス
var banned = ['検閲するID1, 検閲するID2'];
のようにシングルクォーテーションを付け忘れていました
正しい連名の連ね方
var banned = ['検閲するID1', '検閲するID2'];
とし、#9 を動作確認行えました。
該当者のトピックは非表示になり、トピック内に該当者のコメントがあれば
本文とコメント内容に censored と表示され、見なくて済みます。
すっきりして、とても見易いです。
Firefox利用が便利になりました。
フィードリーダー利用の解決とは別ですが、これはこれですごく良いです。
ありがとうございます。
ちなみにFirefoxでは動いたgreasemonkyスクリプト、案の定Epiphanyでは動きません。
オフライン