IP2 ENHANCER

This script adds video thumbnails to IP2 and fixes various issues with video playback. Message /u/ChangThunderwang for bugs and anything related to this.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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!)

Advertisement:

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!)

Advertisement:

May akda
changthunderwang
Mga pang araw araw na pag install
0
Kabuuan na installs
38
Mga Rating
0 0 0
Bersyon
2.3
Nilikha
2021-04-25
Na update
2022-01-08
Laki
7.64 KB
Lisensya
Wala
Nalalapat sa

// ==UserScript==
// @name IP2 VideoFix
// @description This script ads video thumbnails to IP2 and fixes various issues with video playback. Message /u/ChangThunderwang for bugs and anything related to this.
// @grant GM_addStyle
// @version 1.1
// @match *://ip2always.win/*
// @match *://communities.win/*
// @namespace https://greasyfork.org/users/764563
// ==/UserScript==
/*jshint esversion: 6 */


// Fixes video CSS so that videos don't get cut off
GM_addStyle(`
@media only screen and (min-width:973px) {
body .post-list div.content.link div.inner{
background: rgba(0,0,0,0)!important;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
}
.post-list .content {
margin: 8px 0 0 180px;
}
.post-list .content .inner {
padding: 0
}
.video-container.iframe-parent{
position: relative;
overflow: hidden;
width: 100%;
padding-top: 56.25%;
}
.video-container.iframe-parent > .responsive-iframe {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
}
.video-container {
margin: 0px;
padding: 0px;
overflow: inherit;
height: auto;
}
.video-container video{
max-height: 33vw;
}
}
`);

//Removes old handler for the expand buttons on videos upon mouseover. This is delayed to allow the site code to load first.
var once = false;
$(document).on("mouseover", '[data-action="expand"]', function () {
if (!once) {
$(document).off("click", '[data-action="expand"]');
once = true;
} else {
$(document).off("mouseover", '[data-action="expand"]');
}
});

window.onload = function () {
$(document).off("click", '[data-action="expand"]');
}

//Assigns new improved handler for video embeds which removes video tags upon closing
$(document).on("click", 'a[data-action="expand"], .thumb[data-action="expand"]', function () {
$(document).off("click", '[data-action="expand"]');
content = $(this).closest(".post").find(".content").first();
if (content.attr("data-opened") != null) {
return;
}
content.attr("data-opened", true);
if (
content.find("img").first().length &&
content.find("img").first().attr("src") === ""
) {
content
.find("img")
.first()
.attr("src", content.find("img").first().data("src"));
} else if (content.find(".video-container").first().length) {
var first = content.find(".video-container").first();
if ($.trim(content.find(".video-container").first().html()) === "") {
if (
first.hasClass("mp4") ||
/.+(\.mp4|\.mov|\.webm)/i.test(first.data("src"))
) {
content
.find(".video-container")
.first()
.append(
''
);
var vid = content.find(".video-container > video.child-content");
} else {
content
.find(".video-container")
.first()
.append(
''
);
content
.find(".video-container")
.first().addClass('iframe-parent')
}
}
}
content.find("img").first().removeAttr("data-src");
content.find("img").first().removeData("src");
content.slideToggle(0, function () {
content.removeAttr("data-opened");
if (content.is(":hidden")) {
var children = content.find(".child-content");
children.remove();
}
});
});