Skip to content

Instantly share code, notes, and snippets.

@eeeschwartz
Last active December 16, 2016 19:24
Show Gist options
  • Save eeeschwartz/fcb697eef4dd96a6f6ae138d8b9d20af to your computer and use it in GitHub Desktop.
Save eeeschwartz/fcb697eef4dd96a6f6ae138d8b9d20af to your computer and use it in GitHub Desktop.
Diff bookmarklet
var $ = jQuery;
$.ajax({
url: $('link[rel="latest-version"').prop('href')
}).done(function(data){
var fullPageHTML = $.parseHTML(data);
var $contentB = $(fullPageHTML).find('.lex-region-content article');
$contentB.find('.workbench-moderation-entity-moderation-form').hide();
html2canvas($('.lex-region-content article'), {
onrendered: function(canvas) {
var image1, image2;
$('.lex-region-content article').html($contentB.html());
image1 = canvas;
html2canvas($('.lex-region-content article'), {
onrendered: function(canvas) {
image2 = canvas;
c = imagediff.diff(image1, image2);
var resultCanvas = imagediff.createCanvas();
resultCanvas.width = image1.width;
resultCanvas.height = image1.height;
context = resultCanvas.getContext('2d');
context.putImageData(c, 0, 0);
$('.lex-region-content article').prepend(resultCanvas);
}
});
}
});
});
<a href="javascript:void(function () {
var jsCode = document.createElement('script');
jsCode.setAttribute('src', 'https://gist.githubusercontent.com/eeeschwartz/fcb697eef4dd96a6f6ae138d8b9d20af/raw/diff-content-versions.js');
document.body.appendChild(jsCode);
}())">View differences</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment