diff --git a/Plugins/AutoPlayGifs.plugin.js b/Plugins/AutoPlayGifs.plugin.js
index f7e3b8d..ef61e8c 100644
--- a/Plugins/AutoPlayGifs.plugin.js
+++ b/Plugins/AutoPlayGifs.plugin.js
@@ -2,23 +2,47 @@
var agif = function () {};
-agif.prototype.convert = function () {
- $(".image canvas").each(function() {
- var src = $(this).attr("src");
- if(src != undefined) {
- $(this).replaceWith('');
+// 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($("", {
+ src: canvas.attr("src"),
+ width: canvas.attr("width"),
+ height: canvas.attr("height"),
+ }).addClass("image kawaii-autogif"));
}
});
+
+ // 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();
+ });
};
-agif.prototype.onMessage = function () {
- this.convert();
-};
-agif.prototype.onSwitch = function () {
- this.convert();
-};
+agif.prototype.onMessage = function () {};
+
+agif.prototype.onSwitch = function () {};
+
agif.prototype.start = function () {
- this.convert();
+ this.convert(document);
+};
+
+agif.prototype.observer = function (e) {
+ this.convert(e.target);
};
agif.prototype.load = function () {};
@@ -35,8 +59,8 @@ agif.prototype.getDescription = function () {
return "Autoplay gifs without having to hover.";
};
agif.prototype.getVersion = function () {
- return "0.1.0";
+ return "1.0.0";
};
agif.prototype.getAuthor = function () {
- return "Jiiks";
-};
\ No newline at end of file
+ return "noodlebox";
+};