2016-02-09 18:08:20 +01:00
|
|
|
//META{"name":"agif"}*//
|
|
|
|
|
|
|
|
var agif = function () {};
|
|
|
|
|
2016-09-10 12:06:17 +02:00
|
|
|
// Autoplay GIFs
|
|
|
|
agif.prototype.convert = function (target) {
|
|
|
|
// Handle GIF
|
|
|
|
$(target).find(".image:has(canvas)").each(function () {
|
|
|
|
var image = $(this);
|
|
|
|
var canvas = image.children("canvas").first();
|
|
|
|
// Replace GIF preview with actual image
|
|
|
|
var src = canvas.attr("src");
|
|
|
|
if(src !== undefined) {
|
|
|
|
image.replaceWith($("<img>", {
|
|
|
|
src: canvas.attr("src"),
|
|
|
|
width: canvas.attr("width"),
|
|
|
|
height: canvas.attr("height"),
|
|
|
|
}).addClass("image kawaii-autogif"));
|
2016-03-31 09:31:17 +02:00
|
|
|
}
|
2016-02-09 18:08:20 +01:00
|
|
|
});
|
|
|
|
|
2016-09-10 12:06:17 +02:00
|
|
|
// Handle GIFV
|
|
|
|
$(target).find(".embed-thumbnail-gifv:has(video)").each(function () {
|
|
|
|
var embed = $(this);
|
|
|
|
var video = embed.children("video").first();
|
|
|
|
// Remove the class, embed-thumbnail-gifv, to avoid the "GIF" overlay
|
|
|
|
embed.removeClass("embed-thumbnail-gifv").addClass("kawaii-autogif");
|
|
|
|
// Prevent the default behavior of pausing the video
|
|
|
|
embed.parent().on("mouseout.autoGif", function (event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
});
|
|
|
|
video[0].play();
|
|
|
|
});
|
2016-02-09 18:08:20 +01:00
|
|
|
};
|
2016-09-10 12:06:17 +02:00
|
|
|
|
|
|
|
agif.prototype.onMessage = function () {};
|
|
|
|
|
|
|
|
agif.prototype.onSwitch = function () {};
|
|
|
|
|
2016-02-09 18:08:20 +01:00
|
|
|
agif.prototype.start = function () {
|
2016-09-10 12:06:17 +02:00
|
|
|
this.convert(document);
|
|
|
|
};
|
|
|
|
|
|
|
|
agif.prototype.observer = function (e) {
|
|
|
|
this.convert(e.target);
|
2016-02-09 18:08:20 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
agif.prototype.load = function () {};
|
|
|
|
agif.prototype.unload = function () {};
|
|
|
|
agif.prototype.stop = function () {};
|
|
|
|
agif.prototype.getSettingsPanel = function () {
|
|
|
|
return "";
|
|
|
|
};
|
|
|
|
|
|
|
|
agif.prototype.getName = function () {
|
|
|
|
return "Autogif";
|
|
|
|
};
|
|
|
|
agif.prototype.getDescription = function () {
|
2016-03-31 09:15:39 +02:00
|
|
|
return "Autoplay gifs without having to hover.";
|
2016-02-09 18:08:20 +01:00
|
|
|
};
|
|
|
|
agif.prototype.getVersion = function () {
|
2016-09-10 12:06:17 +02:00
|
|
|
return "1.0.0";
|
2016-02-09 18:08:20 +01:00
|
|
|
};
|
|
|
|
agif.prototype.getAuthor = function () {
|
2016-09-10 12:06:17 +02:00
|
|
|
return "noodlebox";
|
|
|
|
};
|