iFunny Video Resize

Resizes videos on iFunny to match browser window height.

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         iFunny Video Resize
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Resizes videos on iFunny to match browser window height.
// @author       Zeval
// @match        https://ifunny.co/video/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ifunny.co
// @grant        none
// ==/UserScript==

(function () {
	'use strict';
	try {
		var vids = document.getElementsByTagName('video');
		console.log(vids);
		let headerHeight = 56;
		let newHeight = (window.innerHeight - headerHeight).toString() + 'px';

		if (!vids) return;
		// add top padding so video is not put behind header
		vids[0].parentElement.parentElement.parentElement.parentElement.parentElement.style.paddingTop =
			headerHeight.toString() + 'px';
		// resize vid
		vids[0].style.height = newHeight;
		// resize parent divs and comments
		vids[0].parentElement.style.height = newHeight;
		vids[0].parentElement.parentElement.style.height = newHeight;
		vids[0].parentElement.parentElement.parentElement.style.height = newHeight;
		vids[0].parentElement.parentElement.parentElement.parentElement.style.height = newHeight;
		vids[0].parentElement.parentElement.style.paddingTop = '0px';

		document.getElementById('comments').style.paddingTop = '170px';
	} catch (e) {
		console.error(e);
	}
})();