From da190439b067245cde3df2423d4a43563ef94ab2 Mon Sep 17 00:00:00 2001 From: EarlgreyPicard Date: Tue, 2 Feb 2016 00:21:55 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E3=81=AE?= =?UTF-8?q?=E3=82=B5=E3=83=8B=E3=82=BF=E3=82=A4=E3=82=BA=E5=87=A6=E7=90=86?= =?UTF-8?q?=E3=82=92=E3=82=AA=E3=83=97=E3=82=B7=E3=83=A7=E3=83=B3=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chrome/content/foxage2ch/findThread.js | 2 +- chrome/content/foxage2ch/import.js | 3 +-- components/service.js | 6 ++---- defaults/preferences/foxage2ch-prefs.js | 2 ++ modules/utils.jsm | 17 +++++++++-------- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/chrome/content/foxage2ch/findThread.js b/chrome/content/foxage2ch/findThread.js index 3ec879b..50732a0 100644 --- a/chrome/content/foxage2ch/findThread.js +++ b/chrome/content/foxage2ch/findThread.js @@ -78,7 +78,7 @@ var FindThread = { key: RegExp.$1, created: parseInt(RegExp.$1, 10) * 1000 * 1000, lastRes: parseInt(RegExp.$3, 10), - title: FoxAge2chUtils.unescapeEntities(FoxAge2chUtils.sanitizeTitle(RegExp.$2)) + title: FoxAge2chUtils.sanitizeTitle(FoxAge2chUtils.unescapeEntities(RegExp.$2)) }); }, this); this.owner.wizard.canAdvance = true; diff --git a/chrome/content/foxage2ch/import.js b/chrome/content/foxage2ch/import.js index b4976e0..4e5faf9 100644 --- a/chrome/content/foxage2ch/import.js +++ b/chrome/content/foxage2ch/import.js @@ -204,8 +204,7 @@ var ImportProcessor = { var type = this._getProperty(res, "type"); var title = this._getProperty(res, "title"); var status = this._getProperty(res, "status"); - title = FoxAge2chUtils.unescapeEntities(title); - title = FoxAge2chUtils.sanitizeTitle(title); + title = FoxAge2chUtils.sanitizeTitle(FoxAge2chUtils.unescapeEntities(title)); var flags = 0; if (status.indexOf("checking") >= 0) flags |= FoxAge2chUtils.STATUS_CHECKING; diff --git a/components/service.js b/components/service.js index 2768157..e4d904b 100644 --- a/components/service.js +++ b/components/service.js @@ -736,8 +736,7 @@ FoxAge2chService.prototype = { ? /

([^<]+)<\/h1>/i : /([^<]+)<\/title>/i; if (pattern.test(aResponseText)) { var title = RegExp.$1; - title = FoxAge2chUtils.unescapeEntities(title); - title = FoxAge2chUtils.sanitizeTitle(title); + title = FoxAge2chUtils.sanitizeTitle(FoxAge2chUtils.unescapeEntities(title)); if (item.type == FoxAge2chUtils.TYPE_BOARD) // 「@2ch掲示板」「@bbspink掲示板」などをカット title = title.replace(/\uFF20.+$/, ""); @@ -787,8 +786,7 @@ FoxAge2chService.prototype = { var pattern = new RegExp(dat + "\\.(?:dat<>|cgi,)(.+)\\s*\\(\\d+\\)"); if (pattern.test(aResponseText)) { var title = RegExp.$1; - title = FoxAge2chUtils.unescapeEntities(title); - title = FoxAge2chUtils.sanitizeTitle(title); + title = FoxAge2chUtils.sanitizeTitle(FoxAge2chUtils.unescapeEntities(title)); FoxAge2chUtils.service.changeItemProperty(item, "title", title); FoxAge2chUtils.rebuildTree(item.id); FoxAge2chUtils.showMessage(FoxAge2chUtils.getLocaleString("SUCCESS")); diff --git a/defaults/preferences/foxage2ch-prefs.js b/defaults/preferences/foxage2ch-prefs.js index 5866ae4..4b7a27a 100644 --- a/defaults/preferences/foxage2ch-prefs.js +++ b/defaults/preferences/foxage2ch-prefs.js @@ -17,3 +17,5 @@ pref("extensions.foxage2ch.loadInterval", 3); pref("extensions.foxage2ch.dataDir.default", true); pref("extensions.foxage2ch.dataDir.path", ""); pref("extensions.foxage2ch.maxBackups", 5); +pref("extensions.foxage2ch.removeAutoAddedWords", true); +pref("extensions.foxage2ch.removeDecorations", true); diff --git a/modules/utils.jsm b/modules/utils.jsm index 5f45ed5..81ca357 100644 --- a/modules/utils.jsm +++ b/modules/utils.jsm @@ -438,24 +438,25 @@ var FoxAge2chUtils = { }; }, - // 「&」「<」「>」「"」の実体参照をデコードする + // 「&」「<」「>」「"」「©」の文字参照をデコードする unescapeEntities: function F2U_unescapeEntities(aString) { aString = aString.replace(/&/g, '&'); aString = aString.replace(/</g, '<'); aString = aString.replace(/>/g, '>'); aString = aString.replace(/"/g, '"'); + aString = aString.replace(/©|©/g, '\u00A9'); return aString; }, // タイトルの余計な文字列を削除する sanitizeTitle: function F2U_sanitizeTitle(aTitle) { - aTitle = aTitle.replace("[\u8EE2\u8F09\u7981\u6B62]", "", "g"); // [転載禁止] - aTitle = aTitle.replace("[\u7121\u65AD\u8EE2\u8F09\u7981\u6B62]", "", "g"); // [無断転載禁止] - aTitle = aTitle.replace("©2ch.net", "", "g"); // ©2ch.net - aTitle = aTitle.replace("©2ch.net", "", "g"); // ©2ch.net - aTitle = aTitle.replace("©bbspink.com", "", "g"); // ©bbspink.com - aTitle = aTitle.replace("©bbspink.com", "", "g"); // @bbspink.com - aTitle = aTitle.replace(/\u25A0|\u25C6|\u25CF|\u2605|\u2606/g, " "); // ■,◆,●,★,☆ + if (FoxAge2chUtils.prefs.getBoolPref("removeAutoAddedWords")) { + aTitle = aTitle.replace(/\[(?:\u7121\u65AD)?\u8EE2\u8F09\u7981\u6B62\]/g, ""); // [無断転載禁止],[転載禁止] + aTitle = aTitle.replace(/\u00A9(?:2ch\.net|bbspink\.com)/g, ""); // ©2ch.net,©bbspink.com + } + if (FoxAge2chUtils.prefs.getBoolPref("removeDecorations")) { + aTitle = aTitle.replace(/\u25A0|\u25A1|\u25C6|\u25C7|\u25CF|\u25CB|\u2605|\u2606|\u25B2|\u25B3|\u25BC|\u25BD/g, " "); // ■,□,◆,◇,●,○,★,☆,▲,△,▼,▽ + } aTitle = aTitle.replace(/[\u0000-\u001F]/g, ""); // 制御文字 aTitle = aTitle.replace(/\s+/g, " "); // 連続する空白 aTitle = aTitle.replace(/^\s+|\s+$/g, ""); // 先頭・末尾の空白