loadedNode

检测节点是否完全加载

As of 2020-04-07. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/399868/789297/loadedNode.js

  1. // ==UserScript==
  2. // @name loadedNode
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 检测节点是否完全加载
  6. // @author YiJie
  7. // @grant none
  8. // ==/UserScript==
  9.  
  10. (function() {
  11. 'use strict';
  12. jQuery.fn.loadedNode = function (selector, func, times, interval) {
  13. var _times = times || -1,
  14. _interval = interval || 100,
  15. _self = $(_selector),
  16. _selector = selector,
  17. _iIntervalID;
  18. if( _self.length ){
  19. func && func.call(_self);
  20. } else {
  21. _iIntervalID = setInterval(function() {
  22. if(!_times) {
  23. clearInterval(_iIntervalID);
  24. }
  25. _times <= 0 || _times--;
  26. _self = $(_selector);
  27. if( _self.length ) {
  28. func && func.call(_self);
  29. clearInterval(_iIntervalID);
  30. }
  31. }, _interval);
  32. }
  33. return this;
  34. }
  35. })();