[Neil Fraser Diff Demo] Enhanced Output View

Easier to compare between corrections, especially for Japanese.

ของเมื่อวันที่ 30-05-2016 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        [Neil Fraser Diff Demo] Enhanced Output View
// @namespace   NFDiff_KK
// @description	Easier to compare between corrections, especially for Japanese.
// @include     https://neil.fraser.name/software/diff_match_patch/svn/trunk/demos/demo_diff.html
// @version     1.1
// @grant       none
// ==/UserScript==

document.getElementsByTagName('input')[5].addEventListener('click', function() {
	//Get output
	var outputdiv = document.getElementById('outputdiv');
	var output = outputdiv.getElementsByTagName('*');
	//Sort output
	var original = '';
	var correction = '';
	for (var i = 0; i < output.length; i++){
		if (output[i].tagName == "SPAN"){
			original += output[i].outerHTML;
			correction += output[i].outerHTML;
		}
		else if (output[i].tagName == "DEL"){
			original += output[i].outerHTML;
		}
		else if (output[i].tagName == "INS"){
			correction += output[i].outerHTML;
		}
	}
	//Replace highlight with text color (for better copying into word docs, etc)
	original = original.replace(/style="background:#ffe6e6;"/igm, 'style="color:red;"');
	correction = correction.replace(/style="background:#e6ffe6;"/igm, 'style="color:green;"');
	//Rewrite output
	outputdiv.innerHTML = '<table border="1" cellspacing="5" cellpadding="5" style="width:100%; border-collapse: collapse;"><tr><td width="50%">' + original + '</td><td width="50%">' + correction + '</td></tr></table>';
}, false);