Greasy Fork

Greasy Fork is available in English.

抽屉评论本页打开

抽屉打开评论区直接本页显示

当前为 2019-07-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         		抽屉评论本页打开
// @version      		1.0.1
// @icon            	https://dig.chouti.com/images/favicon-d38b877458.png
// @description  	    抽屉打开评论区直接本页显示
// @author       		mjc
// @create          	2019-07-01
// @match        		https://dig.chouti.com/*
// @exclude         	https://dig.chouti.com/zone/video/
// @exclude         	https://dig.chouti.com/publish/links/cdu_*
// @exclude         	https://dig.chouti.com/voted/links/cdu_*
// @namespace http://greasyfork.icu/users/212546
// ==/UserScript==

(function () {
	'use strict';
	$(function () {
		//监听
		$(".outer-container").on("click", "a.operate-item.comment", function (e) {
			if ($(this).parents(".link-item").find("#comment-iframe").length > 0) {
				$("#comment-iframe").remove();
				return false;
			}
			if($("#comment-iframe").length > 0){
				$("#comment-iframe").remove();
				$(this).parents(".link-item")[0].scrollIntoView();
			}
			var iframe_content = '<iframe scrolling="no" id="comment-iframe" frameborder="0" src="' + this.href + '" style="width: 840px;padding: 20px 20px;height: 600px;border: 0;"></iframe>';
			$(this).parents(".link-item").append(iframe_content);
			$("#comment-iframe").load(function () {
				var content = $("#comment-iframe").contents();
				content.find(".comment-area").css({
					position: "fixed",
					"top": 0
				});
				var removeInterval = setInterval(() => {
						content.find(".header-fix").remove();
						content.find(".link-area").remove();
						content.find(".extra").remove();
						content.find(".original-link-area").remove();
						content.find(".original-link-top-area").remove();
						content.find(".original-link-operate-con").remove();
					}, 100);
				var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
				var observer = new MutationObserver(function (mutations) {
						mutations.forEach(function (mutation) {
							if (mutation.type == "attributes") {
								setTimeout(function () {
									$("#comment-iframe").height(content.find(".comment-area").innerHeight());
									clearInterval(removeInterval);
								}, 100);
							}
						});
					});
				observer.observe(content.find(".comment-loading-con")[0], {
					attributes: true
				});
			});
			return false;
		});
		$('.msg-alert,.loading-more-btn').on('click', function () {
			$('#comment-iframe').remove();
		});
		$('body').on('click', function () {
			if ($('#comment-iframe').length > 0) {
				$('#comment-iframe').parent()[0].scrollIntoView();
				$('#comment-iframe').remove();
			};
		});
	});
})();