jQuery-loadedNode

检测节点是否完全加载

สคริปต์นี้ไม่ควรถูกติดตั้งโดยตรง มันเป็นคลังสำหรับสคริปต์อื่น ๆ เพื่อบรรจุด้วยคำสั่งเมทา // @require https://update.greasyfork.org/scripts/399868/790609/jQuery-loadedNode.js

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

// ==UserScript==
// @name         jQuery-loadedNode
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  检测节点是否完全加载
// @author       YiJie
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
	try{
		if(typeof jQuery=="undefined") return;
	}catch{return;}
	jQuery.fn.loadedNode = function (selector, func, times, interval) {
		var _times = times || -1,
		_interval = interval || 100,
		_self = $(_selector),
		_selector = selector,
		_iIntervalID;
		if( _self.length ){
			func && func.call(_self);
		} else {
			_iIntervalID = setInterval(function() {
				if(!_times) {
					clearInterval(_iIntervalID);
				}
				_times <= 0 || _times--;
				_self = $(_selector);
				if( _self.length ) {
					func && func.call(_self);
					clearInterval(_iIntervalID);
				}
			}, _interval);
		}
		return this;
	}
})();