0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

閲覧中のページタイトルを自動で書き換える

Posted at
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ポリシーです。
でも、普通のニュース記事でもタブが落ちるのはさすがにヒドイ。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?