loadedNode

检测节点是否完全加载

当前为 2020-04-10 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/399868/790606/loadedNode.js

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