diff --git a/README.md b/README.md index 5000f2c..1647553 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,17 @@ Twitterが優遇するクソメディアはどんどん非表示にする予定 4. 完了 ## CHANGELOG +### Ver. 0.5.0 +- 謎の空白が表示されるのを修正 +- 互換性を維持すると結局スマートにはならなかった +### Ver. 0.4.0 +- フリーワード機能 +- データの持ち方を変更(フリーワードに対応するために・既存データとの互換性を検討中) ### Ver. 0.3.0 - 海外対応 +### Ver. 0.2.12 +- add 色々なメディア +- add コスモポリタン ### Ver. 0.2.11 - checkboxのバグ修正 by @umezaki1212 ### Ver. 0.2.10 diff --git a/src/main.js b/src/main.js index c209e14..ac62bd2 100644 --- a/src/main.js +++ b/src/main.js @@ -1,165 +1,272 @@ +const MUTE_LIST = [ + { + "id": "itm_nlab", + "default_value": false, + "mute_word": ["ねとらぼ"] + }, + { + "id": "ABEMATIMES", + "default_value": false, + "mute_word": ["ABEMA TIMES"] + }, + { + "id": "kyodo_official", + "default_value": false, + "mute_word": ["共同通信"] + }, + { + "id" : "Newsweek_JAPAN", + "default_value": false, + "mute_word": ["ニューズウィーク"] + }, + { + "id": "WomanExcite", + "default_value": false, + "mute_word": ["ウーマンエキサイト編集部"] + }, + { + "id": "iVoCE", + "default_value": false, + "mute_word": ["VOCE", "ヴォーチェ"] + }, + { + "id": "Kstyle_news", + "default_value": false, + "mute_word": ["Kstyle"] + }, + { + "id": "cosmopolitanjp", + "default_value": false, + "mute_word": ["Cosmopolitan", "コスモポリタン"] + }, + { + "id": "bizble_asahi", + "default_value": false, + "mute_word": ["bizble", "ビズブル"] + }, + { + "id": "mimollet2015", + "default_value": false, + "mute_word": ["mi-mollet", "ミモレ"] + }, + { + "id": "news_mynavi_jp", + "default_value": false, + "mute_word": ["マイナビニュース"] + }, + { + "id": "trend_covid19", + "default_value": false, + "mute_word": ["COVID-19"] + }, + { + "id": "oricon", + "default_value": false, + "mute_word": ["ORICON NEWS"] + }, + { + "id": "modelpress", + "default_value": false, + "mute_word": ["モデルプレス"] + }, + { + "id": "ld_blogos", + "default_value": false, + "mute_word": ["BLOGOS"] + }, + { + "id": "japanacademy", + "default_value": false, + "mute_word": ["日本アカデミー賞協会"] + }, + { + "id": "ntvnewszero", + "default_value": false, + "mute_word": ["news zero"] + }, + { + "id": "mamadaystv", + "default_value": false, + "mute_word": ["MAMADAYS", "ママデイズ"] + }, + { + "id": "BIJapan", + "default_value": false, + "mute_word": ["Business Insider Japan"] + }, + { + "id": "GINZA_magazine", + "default_value": false, + "mute_word": ["GINZA"] + }, + { + "id": "auto_scroll_by_1", + "default_value": false, + "mute_word": [] + }, + { + "id": "word_birthday", + "default_value": false, + "mute_word": ["誕生日"] + }, + { + "id": "mute_level_hard", + "default_value": false, + "mute_word": [] + }, + { + "id": "sankeibiz", + "default_value": false, + "mute_word": ["SankeiBiz"] + }, + { + "id": "nhk_news", + "default_value": false, + "mute_word": ["NHKニュース", "NHK NEWS"] + }, + { + "id": "word_china", + "default_value": false, + "mute_word": ["中国"] + }, + { + "id": "word_korea", + "default_value": false, + "mute_word": ["韓国"] + }, + { + "id": "tastyjapan", + "default_value": false, + "mute_word": ["Tasty Japan"] + }, + { + "id": "frau_tw", + "default_value": false, + "mute_word": ["FRaU"] + }, + { + "id": "gekisaka", + "default_value": false, + "mute_word": ["ゲキサカ"] + }, + { + "id": "gendai_biz", + "default_value": false, + "mute_word": ["現代ビジネス"] + }, + { + "id": "word_BTS", + "default_value": false, + "mute_word": ["BTS"] + }, + { + "id": "shin_R25", + "default_value": false, + "mute_word": ["新R25編集部"] + }, + { + "id": "crea_web", + "default_value": false, + "mute_word": ["CREA"] + }, + { + "id": "hst_tvasahi", + "default_value": false, + "mute_word": ["報道ステーション"] + }, + { + "id": "news24ntv", + "default_value": false, + "mute_word": ["日テレNEWS"] + }, + { + "id": "jijicom", + "default_value": false, + "mute_word": ["時事ドットコム"] + }, + { + "id": "trend_kpop", + "default_value": false, + "mute_word": ["K-POP · トレンド"] + }, + { + "id": "trend_seiji", + "default_value": false, + "mute_word": ["政治 · トレンド"] + }, + { + "id": "jijimedical", + "default_value": false, + "mute_word": ["時事メディカル"] + }, + { + "id": "numberweb", + "default_value": false, + "mute_word": ["Number編集部"] + }, + { + "id": "asahicom", + "default_value": false, + "mute_word": ["朝日新聞", "AREA"] + }, + { + "id": "toyokeizai", + "default_value": false, + "mute_word": ["東洋経済"] + }, + { + "id": "fnn", + "default_value": false, + "mute_word": ["FNN"] + }, + { + "id": "bunshun", + "default_value": false, + "mute_word": ["文春"] + }, + { + "id": "huffpost", + "default_value": true, + "mute_word": ["ハフポスト"] + }, + { + "id": "buzzfeed", + "default_value": true, + "mute_word": ["BuzzFeed", "バズフィード"] + }, + { + "id": "mode_overseas", + "default_value": false, + "mute_word": [] + }, + { + "id": "move_hard_translate_y_help", + "default_value": false, + "mute_word": [] + }, + { + "id": "apply_new_mute_list", + "default_value": false, + "mute_word": [] + } +]; +// --- let muteCounter = 0; -let twitterMute = { - buzzfeed: true, - huffpost: true, - bunshun: false, - fnn: false, - toyokeizai: false, - asahicom: false, - numberweb: false, - jijimedical: false, - trend_seiji: false, - trend_kpop: false, - jijicom: false, - news24ntv: false, - hst_tvasahi: false, - crea_web: false, - shin_R25: false, - word_BTS: false, - gendai_biz: false, - gekisaka: false, - frau_tw: false, - tastyjapan: false, - word_korea: false, - word_china: false, - nhk_news: false, - sankeibiz: false, - mute_level_hard: false, - word_birthday: false, - auto_scroll_by_1: false, - GINZA_magazine: false, - BIJapan: false, - mamadaystv: false, - ntvnewszero: false, - japanacademy: false, - ld_blogos: false, - modelpress: false, - oricon: false, - trend_covid19: false, - news_mynavi_jp: false, - bizble_asahi: false, - mode_overseas: false +let settings = { + mute_list: [] }; const filterFunc = (e) => { - var result = false; - if (twitterMute.buzzfeed) { - result = e.innerText.includes('BuzzFeed') || e.innerText.includes('バズフィード') || result; - } - if (twitterMute.huffpost) { - result = e.innerText.includes('ハフポスト') || result; - } - if (twitterMute.bunshun) { - result = e.innerText.includes('文春') || result; - } - if (twitterMute.fnn) { - result = e.innerText.includes('FNN') || result; - } - if (twitterMute.toyokeizai) { - result = e.innerText.includes('東洋経済') || result; - } - if (twitterMute.asahicom) { - result = e.innerText.includes('朝日新聞') || result; - } - if (twitterMute.numberweb) { - result = e.innerText.includes('Number編集部') || result; - } - if (twitterMute.jijimedical) { - result = e.innerText.includes('時事メディカル') || result; - } - if (twitterMute.trend_seiji) { - result = e.innerText.includes('政治 · トレンド') || result; - } - if (twitterMute.trend_kpop) { - result = e.innerText.includes('K-POP · トレンド') || result; - } - if (twitterMute.jijicom) { - result = e.innerText.includes('時事ドットコム') || result; - } - if (twitterMute.news24ntv) { - result = e.innerText.includes('日テレNEWS') || result; - } - if (twitterMute.hst_tvasahi) { - result = e.innerText.includes('報道ステーション') || result; - } - if (twitterMute.crea_web) { - result = e.innerText.includes('CREA') || result; - } - if (twitterMute.shin_R25) { - result = e.innerText.includes('新R25編集部') || result; - } - if (twitterMute.word_BTS) { - result = e.innerText.includes('BTS') || result; - } - if (twitterMute.gendai_biz) { - result = e.innerText.includes('現代ビジネス') || result; - } - if (twitterMute.gekisaka) { - result = e.innerText.includes('ゲキサカ') || result; - } - if (twitterMute.frau_tw) { - result = e.innerText.includes('FRaU') || result; - } - if (twitterMute.tastyjapan) { - result = e.innerText.includes('Tasty Japan') || result; - } - if (twitterMute.word_korea) { - result = e.innerText.includes('韓国') || result; - } - if (twitterMute.word_china) { - result = e.innerText.includes('中国') || result; - } - if (twitterMute.nhk_news) { - result = e.innerText.includes('NHKニュース') || e.innerText.includes('NHK NEWS') || result; - } - if (twitterMute.sankeibiz) { - result = e.innerText.includes('SankeiBiz') || result; + if (settings.mute_list) { + return settings.mute_list.some((keyword) => e.innerText.includes(keyword)); } - if (twitterMute.word_birthday) { - result = e.innerText.includes('誕生日') || result; - } - if (twitterMute.GINZA_magazine) { - result = e.innerText.includes('GINZA') || result; - } - if (twitterMute.BIJapan) { - result = e.innerText.includes('Business Insider Japan') || result; - } - if (twitterMute.mamadaystv) { - result = e.innerText.includes('MAMADAYS') || e.innerText.includes('ママデイズ') || result; - } - if (twitterMute.ntvnewszero) { - result = e.innerText.includes('news zero') || result; - } - if (twitterMute.japanacademy) { - result = e.innerText.includes('日本アカデミー賞協会') || result; - } - if (twitterMute.ld_blogos) { - result = e.innerText.includes('BLOGOS') || result; - } - if (twitterMute.modelpress) { - result = e.innerText.includes('モデルプレス') || result; - } - if (twitterMute.oricon) { - result = e.innerText.includes('ORICON NEWS') || result; - } - if (twitterMute.trend_covid19) { - result = e.innerText.includes('COVID-19') || result; - } - if (twitterMute.news_mynavi_jp) { - result = e.innerText.includes('マイナビニュース') || result; - } - if (twitterMute.mimollet2015) { - result = e.innerText.includes('mi-mollet') || e.innerText.includes('ミモレ') || result; - } - if (twitterMute.bizble_asahi) { - result = e.innerText.includes('bizble') || e.innerText.includes('ビズブル') || result; - } - return result; + return false; } const observer = new MutationObserver((mutations) => { muteCounter++; if (muteCounter % 3 !== 0) { return; } + console.log(settings); try { [...document.querySelectorAll('div[aria-label="タイムライン: トレンド"] > div > div')] .filter(filterFunc) @@ -167,14 +274,28 @@ const observer = new MutationObserver((mutations) => { [...document.querySelectorAll('div[aria-label="タイムライン: 話題を検索"] > div > div')] .filter(filterFunc) .forEach((e) => e.style.display = 'none'); - if (twitterMute.auto_scroll_by_1) { + + if (settings.move_hard_translate_y) { + [...document.querySelectorAll('div[aria-label="タイムライン: トレンド"] > div > div')] + .filter(filterFunc) + .forEach((e) => e.style.display = undefined); + [...document.querySelectorAll('div[aria-label="タイムライン: 話題を検索"] > div > div')] + .filter(filterFunc) + .forEach((e) => e.style.display = undefined); + [...document.querySelectorAll('div[aria-label="タイムライン: トレンド"] > div > div')] + .filter(filterFunc) + .forEach((e) => e.style.display = 'none'); + [...document.querySelectorAll('div[aria-label="タイムライン: 話題を検索"] > div > div')] + .filter(filterFunc) + .forEach((e) => e.style.display = 'none'); } + if (settings.auto_scroll_by_1) { window.scrollBy(0, 1); window.scrollBy(0, -1); } } catch (e) { console.error(e); } - if (twitterMute.mode_overseas) { + if (settings.mode_overseas) { try { [...document.querySelectorAll('section[aria-labelledby|="accessible-list"] > div > div > div[class]')] .filter(filterFunc) @@ -182,7 +303,7 @@ const observer = new MutationObserver((mutations) => { [...document.querySelectorAll('div > div:nth-child(2) > div > div > section[aria-labelledby^="accessible-list"] > div > div > div')] .filter(filterFunc) .forEach((e) => e.style.display = 'none'); - if (twitterMute.auto_scroll_by_1) { + if (settings.auto_scroll_by_1) { window.scrollBy(0, 1); window.scrollBy(0, -1); } @@ -190,7 +311,7 @@ const observer = new MutationObserver((mutations) => { console.error(e); } } - if (twitterMute.mute_level_hard) { + if (settings.mute_level_hard) { setTimeout(() => { try { [...document.querySelectorAll('div[aria-label="タイムライン: トレンド"] > div > div')] @@ -199,7 +320,7 @@ const observer = new MutationObserver((mutations) => { [...document.querySelectorAll('div[aria-label="タイムライン: 話題を検索"] > div > div')] .filter(filterFunc) .forEach((e) => e.style.display = 'none'); - if (twitterMute.auto_scroll_by_1) { + if (settings.auto_scroll_by_1) { window.scrollBy(0, 1); window.scrollBy(0, -1); } @@ -212,87 +333,32 @@ const observer = new MutationObserver((mutations) => { const config = { attributes: false, childList: true, characterData: false, subtree: true }; observer.observe(document.body, config); -chrome.storage.sync.get({ - buzzfeed: true, - huffpost: true, - bunshun: false, - fnn: false, - toyokeizai: false, - asahicom: false, - numberweb: false, - jijimedical: false, - trend_seiji: false, - trend_kpop: false, - jijicom: false, - news24ntv: false, - hst_tvasahi: false, - crea_web: false, - shin_R25: false, - word_BTS: false, - gendai_biz: false, - gekisaka: false, - frau_tw: false, - tastyjapan: false, - word_korea: false, - word_china: false, - nhk_news: false, - sankeibiz: false, - mute_level_hard: false, - word_birthday: false, +chrome.storage.sync.get(Object.assign({ + mute_list: ["BuzzFeed", "バズフィード", "ハフポスト"], auto_scroll_by_1: false, - GINZA_magazine: false, - BIJapan: false, - mamadaystv: false, - ntvnewszero: false, - japanacademy: false, - ld_blogos: false, - modelpress: false, - oricon: false, - trend_covid19: false, - news_mynavi_jp: false, - mimollet2015: false, - bizble_asahi: false, - mode_overseas: false -}, (items) => { - twitterMute.buzzfeed = items.buzzfeed; - twitterMute.huffpost = items.huffpost; - twitterMute.bunshun = items.bunshun; - twitterMute.fnn = items.fnn; - twitterMute.toyokeizai = items.toyokeizai; - twitterMute.asahicom = items.asahicom; - twitterMute.numberweb = items.numberweb; - twitterMute.jijimedical = items.jijimedical; - twitterMute.trend_seiji = items.trend_seiji; - twitterMute.trend_kpop = items.trend_kpop; - twitterMute.jijicom = items.jijicom; - twitterMute.news24ntv = items.news24ntv; - twitterMute.hst_tvasahi = items.hst_tvasahi; - twitterMute.crea_web = items.crea_web; - twitterMute.shin_R25 = items.shin_R25; - twitterMute.word_BTS = items.word_BTS; - twitterMute.gendai_biz = items.gendai_biz; - twitterMute.gekisaka = items.gekisaka; - twitterMute.frau_tw = items.frau_tw; - twitterMute.tastyjapan = items.tastyjapan; - twitterMute.word_korea = items.word_korea; - twitterMute.word_china = items.word_china; - twitterMute.nhk_news = items.nhk_news; - twitterMute.sankeibiz = items.sankeibiz; - twitterMute.mute_level_hard = items.mute_level_hard; - twitterMute.word_birthday = items.word_birthday; - twitterMute.auto_scroll_by_1 = items.auto_scroll_by_1; - twitterMute.GINZA_magazine = items.GINZA_magazine; - twitterMute.BIJapan = items.BIJapan; - twitterMute.mamadaystv = items.mamadaystv; - twitterMute.ntvnewszero = items.ntvnewszero; - twitterMute.japanacademy = items.japanacademy; - twitterMute.ld_blogos = items.ld_blogos; - twitterMute.modelpress = items.modelpress; - twitterMute.oricon = items.oricon; - twitterMute.trend_covid19 = items.trend_covid19; - twitterMute.news_mynavi_jp = items.news_mynavi_jp; - twitterMute.mimollet2015 = items.mimollet2015; - twitterMute.bizble_asahi = items.bizble_asahi; - twitterMute.mode_overseas = items.mode_overseas; -}); - + mute_level_hard: false, + mode_overseas: false, + move_hard_translate_y: false, + apply_new_mute_list: false +}, MUTE_LIST.reduce((a, c) => { + a[c.id] = c.default_value; + return a; +}, {})), (data) => { + if (!data.apply_new_mute_list) { + var mute_list = data.mute_list.concat(MUTE_LIST.reduce((a, c) => { + if (data[c.id]) { + a = a.concat(c.mute_word); + } + return a; + }, [])); + settings.mute_list = mute_list; + // options + settings.auto_scroll_by_1 = data.auto_scroll_by_1; + settings.mute_level_hard = data.mute_level_hard; + settings.mode_overseas = data.mode_overseas; + settings.move_hard_translate_y = data.move_hard_translate_y; + settings.apply_new_mute_list = data.apply_new_mute_list; + } else { + settings = Object.assign(settings, data); + } +}); \ No newline at end of file diff --git a/src/manifest.json b/src/manifest.json index da1eab1..df36925 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "twitter-mute-buzzfuff", - "version": "0.3.0", + "version": "0.5.0", "description": "鬱陶しいメディアを目に入らなくする", "icons": { "128": "img/128.png", diff --git a/src/options.html b/src/options.html index d3d519c..3ee0af2 100644 --- a/src/options.html +++ b/src/options.html @@ -7,234 +7,12 @@
保存後、Twitterのページをリロードしてください。
-