NGA User Script Loader

NGA User Script Loader 实现两个功能:1.在页面未加载 jQuery 时加载 jQuery ;2.在点击“加载上一页/下一页”按钮后重新运行用户脚本(需脚本自身配合)。

2020/01/20のページです。最新版はこちら

このスクリプトは単体で利用できません。右のようなメタデータを含むスクリプトから、ライブラリとして読み込まれます: // @require https://update.greatest.deepsurf.us/scripts/39014/766910/NGA%20User%20Script%20Loader.js

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
  1. // ==UserScript==
  2. // @name NGA User Script Loader
  3. // @namespace https://greatest.deepsurf.us/zh-CN/scripts/39014-nga-user-script-loader
  4. // @version 0.0.4.20200121
  5. // @icon http://bbs.nga.cn/favicon.ico
  6. // @description NGA User Script Loader 实现两个功能:1.在页面未加载 jQuery 时加载 jQuery ;2.在点击“加载上一页/下一页”按钮后重新运行用户脚本(需脚本自身配合)。
  7. // @author AgLandy
  8. // @include /^https?:\/\/(bbs\.ngacn\.cc|nga\.178\.com|bbs\.nga\.cn)/
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function(){
  13.  
  14. if(!window.commonui)
  15. commonui = {};
  16.  
  17. setTimeout(function(){
  18.  
  19. try{
  20. if(commonui.userScriptLoader.$)
  21. return;
  22. }
  23. catch(e){
  24. let btn = 'a[title^="加载"]',
  25. init = function($){
  26. commonui.userScriptLoader = {
  27. $: $,
  28. userScriptData: {},
  29. reload: function(){
  30. let usl = commonui.userScriptLoader;
  31. if(usl.mo)
  32. return;
  33. usl.mo = new MutationObserver(function(){
  34. $(btn).bind('click.userScriptLoader', usl.reload);
  35. $.each(usl.userScriptData, function(k, v){
  36. v();
  37. });
  38. usl.mo.disconnect();
  39. delete usl.mo;
  40. });
  41. usl.mo.observe($('div#mc')[0], {
  42. childList: true,
  43. subtree: true,
  44. });
  45. },
  46. lS: (function(s){
  47. if(!!s){
  48. try{
  49. s.testkey = 'testvalue';
  50. s.removeItem('testkey');
  51. return true;
  52. }
  53. catch(e){
  54. return false;
  55. }
  56. }
  57. else
  58. return false;
  59. })(window.localStorage)
  60. };
  61. $(btn).bind('click.userScriptLoader', commonui.userScriptLoader.reload);
  62. };
  63. if(typeof jQuery == 'undefined' && !document.getElementById('ngaUSL')){
  64. let s = document.createElement('script');
  65. s.type = 'text/javascript';
  66. s.src = 'https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js';
  67. s.id = 'ngaUSL';
  68. s.onload = s.onreadystatechange = function(){
  69. if(!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState){
  70. init(jQuery.noConflict());
  71. this.onload = this.onreadystatechange = null;
  72. }
  73. };
  74. document.head.appendChild(s);
  75. }
  76. else
  77. init(jQuery);
  78. }
  79.  
  80. }, Math.floor(Math.random() * 1000));
  81.  
  82. })();