censor.js
var observer = new MutationObserver(function(mutations) {
// タイトルが空ならスキップ
if (!document.title) return;
// Googleドメインか(Google系はちょくちょく書き直すので)
var isGoogleDomain = (document.domain.indexOf('google') > -1);
// タイトルを取得
var title = document.title.toLowerCase();
// 「Google Drive」がタイトルに含まれるかチェック
if (title.indexOf('google') == -1) {
if (!isGoogleDomain) observer.disconnect(); // 監視を解除
return;
}
if (title.indexOf('drive') == -1 && title.indexOf('ドライブ') == -1) {
if (!isGoogleDomain) observer.disconnect(); // 監視を解除
return;
}
// 対象文字を「***」に置換
title = title.replace(/google/g, '***');
title = title.replace(/drive/g, '***');
title = title.replace(/ドライブ/g, '***');
document.title = title;
if (!isGoogleDomain) observer.disconnect();
});
observer.observe(document, { subtree: true, characterData: true, childList: true });
社内検閲対策のExtensionを作りました。
contents_scriptsで"run_at": "document_start"かませると、常に監視します。
ページタイトルに「Google ドライブ」と含まれていれば、即「*** ***」に書き換えます。
ちょっとエッチな感じになりますね。
Documentの全変更を検出するので、マシンによってはきついかも。
社内でGoogleドライブの利用を禁止されていて、
ページタイトルに「Google ドライブ」と入ってるとタブが落ちるWindowsポリシーです。
でも、普通のニュース記事でもタブが落ちるのはさすがにヒドイ。