V2EX 增强

自动签到、链接转图片、自动无缝翻页、回到顶部(右键点击两侧空白处)、快速回复(左键双击两侧空白处)、新标签页打开链接、标签页伪装为 Github(摸鱼)

当前为 2021-04-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name V2EX 增强
  3. // @version 1.0.8
  4. // @author X.I.U
  5. // @description 自动签到、链接转图片、自动无缝翻页、回到顶部(右键点击两侧空白处)、快速回复(左键双击两侧空白处)、新标签页打开链接、标签页伪装为 Github(摸鱼)
  6. // @match *://v2ex.com/*
  7. // @match *://*.v2ex.com/*
  8. // @icon https://www.v2ex.com/static/favicon.ico
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_registerMenuCommand
  11. // @grant GM_unregisterMenuCommand
  12. // @grant GM_openInTab
  13. // @grant GM_getValue
  14. // @grant GM_setValue
  15. // @grant GM_notification
  16. // @license GPL-3.0 License
  17. // @run-at document-end
  18. // @namespace https://github.com/XIU2/UserScript
  19. // ==/UserScript==
  20.  
  21. (function() {
  22. var menu_ALL = [
  23. ['menu_autoClockIn', '自动签到', '自动签到', true],
  24. ['menu_linksToImgs', '链接转图片', '链接转图片', true],
  25. ['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],
  26. ['menu_pageLoading_reply', '帖子内自动翻页', '帖子内自动翻页', false],
  27. ['menu_backToTop', '回到顶部(右键点击两侧空白处)', '回到顶部', true],
  28. ['menu_quickReply', '快速回复(左键双击两侧空白处)', '快速回复', true],
  29. ['menu_linksBlank', '新标签页打开链接', '新标签页打开链接', true],
  30. ['menu_fish', '标签页伪装为 Github(摸鱼)', '标签页伪装为 Github', false]
  31. ], menu_ID = [];
  32. for (let i=0;i<menu_ALL.length;i++){ // 如果读取到的值为 null 就写入默认值
  33. if (GM_getValue(menu_ALL[i][0]) == null){GM_setValue(menu_ALL[i][0], menu_ALL[i][3])};
  34. }
  35. registerMenuCommand();
  36.  
  37. // 注册脚本菜单
  38. function registerMenuCommand() {
  39. if (menu_ID.length > menu_ALL.length){ // 如果菜单ID数组多于菜单数组,说明不是首次添加菜单,需要卸载所有脚本菜单
  40. for (let i=0;i<menu_ID.length;i++){
  41. GM_unregisterMenuCommand(menu_ID[i]);
  42. }
  43. }
  44. for (let i=0;i<menu_ALL.length;i++){ // 循环注册脚本菜单
  45. menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
  46. menu_ID[i] = GM_registerMenuCommand(`[ ${menu_ALL[i][3]?'√':'×'} ] ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
  47. }
  48. menu_ID[menu_ID.length] = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/424246/feedback', {active: true,insert: true,setParent: true});});
  49. }
  50.  
  51. // 菜单开关
  52. function menu_switch(menu_status, Name, Tips) {
  53. if (menu_status == 'true'){
  54. GM_setValue(`${Name}`, false);
  55. GM_notification({text: `已关闭 [${Tips}] 功能\n(刷新网页后生效)`, timeout: 3000});
  56. }else{
  57. GM_setValue(`${Name}`, true);
  58. GM_notification({text: `已开启 [${Tips}] 功能\n(刷新网页后生效)`, timeout: 3000});
  59. }
  60. registerMenuCommand(); // 重新注册脚本菜单
  61. };
  62.  
  63. // 返回菜单值
  64. function menu_value(menuName) {
  65. for (let menu of menu_ALL) {
  66. if (menu[0] == menuName) {
  67. return menu[3]
  68. }
  69. }
  70. }
  71.  
  72.  
  73. // 默认 ID 为 0
  74. var curSite = {SiteTypeID: 0};
  75.  
  76. // 自动翻页规则
  77. // HT_insert:1 = 插入该元素本身的前面;2 = 插入该元素当中,第一个子元素前面;3 = 插入该元素当中,最后一个子元素后面;4 = 插入该元素本身的后面;
  78. // scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大
  79. // function:before = 插入前执行函数;after = 插入后执行函数;parameter = 参数
  80. let DBSite = {
  81. recent: { // 最近主题页
  82. SiteTypeID: 1,
  83. pager: {
  84. type: 1,
  85. nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
  86. pageElement: 'css;.cell.item',
  87. HT_insert: ['//div[@id="Main"]//div[@class="box"]//div[@class="cell"][last()]', 1],
  88. replaceE: 'css;#Main > .box > .cell[style]:not(.item) > table',
  89. scrollDelta: 600
  90. },
  91. function: {
  92. after: linksBlank,
  93. parameter: '#Main a.topic-link:not([target])'
  94. }
  95. },
  96. notifications: { // 提醒消息页
  97. SiteTypeID: 2,
  98. pager: {
  99. type: 1,
  100. nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
  101. pageElement: 'css;#notifications > div',
  102. HT_insert: ['css;#notifications', 3],
  103. replaceE: 'css;#Main > .box > .cell[style] > table',
  104. scrollDelta: 1000
  105. },
  106. function: {
  107. after: linksBlank,
  108. parameter: '#Main a[href^="/t/"]:not([target])'
  109. }
  110. },
  111. replies: { // 用户回复页
  112. SiteTypeID: 3,
  113. pager: {
  114. type: 1,
  115. nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
  116. pageElement: '//div[@id="Main"]//div[@class="box"]//div[@class="dock_area"] | //*[@id="Main"]//div[@class="box"]//div[@class="inner"] | //*[@id="Main"]//div[@class="box"]//div[@class="dock_area"][last()]/following-sibling::div[@class="cell"][1]',
  117. HT_insert: ['//div[@id="Main"]//div[@class="box"]//div[@class="cell"][last()]', 1],
  118. replaceE: 'css;#Main > .box > .cell[style] > table',
  119. scrollDelta: 1000
  120. },
  121. function: {
  122. after: linksBlank,
  123. parameter: '#Main a[href^="/t/"]:not([target])'
  124. }
  125. },
  126. go: { // 分类主题页
  127. SiteTypeID: 4,
  128. pager: {
  129. type: 1,
  130. nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
  131. pageElement: 'css;#TopicsNode > div',
  132. HT_insert: ['css;#TopicsNode', 3],
  133. replaceE: 'css;#Main > .box > .cell[style] > table',
  134. scrollDelta: 700
  135. },
  136. function: {
  137. after: linksBlank,
  138. parameter: '#Main a.topic-link:not([target])'
  139. }
  140. },
  141. reply: { // 帖子内容页
  142. SiteTypeID: 5,
  143. pager: {
  144. type: 1,
  145. nextLink: '//a[@class="page_current"]/preceding-sibling::a[1][@href]',
  146. pageElement: 'css;.cell[id^="r_"]',
  147. HT_insert: ['//div[starts-with(@id, "r_")][last()]/following-sibling::div[@class="cell"][1]', 1],
  148. replaceE: 'css;#Main > .box > .cell[style] > table',
  149. scrollDelta: 700
  150. }
  151. },
  152. reply_positive: { // 帖子内容页(正序)
  153. SiteTypeID: 6,
  154. pager: {
  155. type: 1,
  156. nextLink: '//a[@class="page_current"]/preceding-sibling::a[1][@href]',
  157. pageElement: 'css;.cell[id^="r_"]',
  158. HT_insert: ['//div[starts-with(@id, "r_")][1]', 1],
  159. replaceE: 'css;#Main > .box > .cell[style] > table',
  160. scrollDelta: 700
  161. }
  162. },
  163. balance: { // 账户余额页
  164. SiteTypeID: 7,
  165. pager: {
  166. type: 1,
  167. nextLink: '//div[@id="Main"]//div[@class="cell"][last()]//a[@class="page_current"]/following-sibling::a[1][@href]',
  168. pageElement: '//div[@id="Main"]//div[@class="cell"][last()]/preceding-sibling::div[1]//tr[position()>1]',
  169. HT_insert: ['//div[@id="Main"]//div[@class="cell"][last()]/preceding-sibling::div[1]//tr[last()]', 4],
  170. replaceE: 'css;#Main > .box > .cell[style] > table',
  171. scrollDelta: 700
  172. }
  173. }
  174. };
  175.  
  176.  
  177. switch (location.pathname) {
  178. case "/": // 首页
  179. linksBlank('#Main a.topic-link:not([target])');
  180. break;
  181. case "/recent": // 最近主题页
  182. curSite = DBSite.recent;
  183. linksBlank('#Main a.topic-link:not([target])');
  184. break;
  185. case "/notifications": // 提醒消息页
  186. curSite = DBSite.notifications;
  187. linksBlank('#Main a[href^="/t/"]:not([target])');
  188. break;
  189. case "/balance": // 账户余额页
  190. curSite = DBSite.balance;
  191. break;
  192. default:
  193. if (location.pathname.indexOf('/go/') > -1) { // 分类主题页
  194. curSite = DBSite.go;
  195. linksBlank('#Main a.topic-link:not([target])');
  196. } else if (location.pathname.indexOf('/t/') > -1) { // 帖子内容页
  197. if(menu_value('menu_pageLoading_reply'))curSite = DBSite.reply_positive; // 帖子内自动无缝翻页
  198. if(menu_value('menu_quickReply'))quickReply(); // 快速回复(双击左右两侧空白处)
  199. linksBlank('#Main .box .topic_content a:not([href^="/member"]):not([target])');
  200. } else if (location.pathname.indexOf('/replies') > -1) { // 用户回复页
  201. curSite = DBSite.replies;
  202. linksBlank('#Main a[href^="/t/"]:not([target])');
  203. }
  204. }
  205.  
  206. curSite.pageUrl = ""; // 下一页URL
  207. if(menu_value('menu_fish'))fish(); // 标签页伪装为 Github(摸鱼)
  208. if(menu_value('menu_autoClockIn'))setTimeout(qianDao, 1000); // 自动签到(后台),延迟 1 秒执行是为了兼容 [V2ex Plus] 扩展
  209. if(menu_value('menu_pageLoading'))pageLoading(); // 自动翻页(无缝)
  210. if(menu_value('menu_backToTop'))backToTop(); // 回到顶部(右键点击左右两侧空白处)
  211. if(menu_value('menu_linksToImgs'))linksToImgs(); // 链接转图片
  212.  
  213.  
  214. // 自动签到(后台)
  215. function qianDao() {
  216. let timeNow = new Date().getUTCFullYear() + "/" + (new Date().getUTCMonth() + 1) + "/" + new Date().getUTCDate() // 当前 UTC-0 时间(V2EX 按这个时间的)
  217. if (location.pathname == '/') { // 在首页
  218. let qiandao = document.querySelector('.box .inner a[href="/mission/daily"]');
  219. if (qiandao) { // 如果找到了签到提示
  220. qianDao_(qiandao, timeNow); // 后台签到
  221. } else if (document.getElementById('gift_v2excellent')) { // 兼容 [V2ex Plus] 扩展
  222. document.getElementById('gift_v2excellent').click();
  223. GM_setValue('menu_clockInTime', timeNow); // 写入签到时间以供后续比较
  224. } else { // 都没有找到,说明已经签过到了
  225. console.log('已经签过到了。')
  226. }
  227. } else { // 不在首页
  228. let timeOld = GM_getValue('menu_clockInTime')
  229. if (!timeOld || timeOld != timeNow) {
  230. qianDaoStatus_(timeNow) // 后台获取签到状态(并判断是否需要签到)
  231. } else { // 新旧签到时间一致
  232. console.log('已经签过到了。')
  233. }
  234. }
  235. }
  236.  
  237.  
  238. // 后台签到
  239. function qianDao_(qiandao, timeNow) {
  240. let url = (location.origin + "/mission/daily/redeem?" + RegExp("once\\=(\\d+)").exec(document.querySelector('div#Top .tools').innerHTML)[0]);
  241. GM_xmlhttpRequest({
  242. url: url,
  243. method: "GET",
  244. timeout: 5000,
  245. onload: function (response) {
  246. let html = ShowPager.createDocumentByString(response.responseText);
  247. if (html.querySelector('li.fa.fa-ok-sign')) {
  248. html = html.getElementById('Main').innerText.match(/已连续登录 (\d+?) 天/)[0];
  249. GM_setValue('menu_clockInTime', timeNow); // 写入签到时间以供后续比较
  250. console.log('自动签到完成!')
  251. if (qiandao) {
  252. qiandao.innerText = `自动签到完成!${html}`;
  253. qiandao.href = '#';
  254. }
  255. } else {
  256. GM_notification({text: '自动签到失败!请联系作者解决!', timeout: 4000, onclick() {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/424246/feedback', {active: true,insert: true,setParent: true});}});
  257. if (qiandao) qiandao.innerText = '自动签到失败!请尝试手动签到!';
  258. }
  259. }
  260. });
  261. }
  262.  
  263.  
  264. // 后台获取签到状态(并判断是否需要签到)
  265. function qianDaoStatus_(timeNow) {
  266. GM_xmlhttpRequest({
  267. url: 'https://www.v2ex.com/mission/daily',
  268. method: "GET",
  269. timeout: 5000,
  270. onload: function (response) {
  271. let html = ShowPager.createDocumentByString(response.responseText);
  272. if (html.querySelector('input[value^="领取"]')) { // 还没有签到...
  273. qianDao_(null, timeNow); // 后台签到
  274. } else { // 已经签到了...
  275. console.log('已经签过到了。')
  276. GM_setValue('menu_clockInTime', timeNow); // 写入签到时间以供后续比较
  277. }
  278. }
  279. });
  280. }
  281.  
  282.  
  283. // 回到顶部(右键左右两侧空白处)
  284. function backToTop() {
  285. document.getElementById("Wrapper").oncontextmenu = document.querySelector("#Wrapper > .content").oncontextmenu = function(event){
  286. if (event.target==this) {
  287. event.preventDefault();
  288. window.scrollTo(0,0)
  289. }
  290. }
  291. }
  292.  
  293.  
  294. // 标签页伪装为 Github(摸鱼)
  295. function fish() {
  296. window.document.title = 'GitHub'
  297. if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
  298. document.querySelector("link[rel*='shortcut icon']").href = 'https://github.githubassets.com/favicons/favicon-dark.png'
  299. } else {
  300. document.querySelector("link[rel*='shortcut icon']").href = 'https://github.githubassets.com/favicons/favicon.png'
  301. }
  302. }
  303.  
  304.  
  305. // 链接转图片,修改自:https://greasyfork.org/scripts/14182
  306. function linksToImgs() {
  307. let links = document.links;
  308. Array.from(links).forEach(function (_this) {
  309. if (/^https.*\.(?:jpg|jpeg|jpe|bmp|png|gif)/i.test(_this.href) && !(/<img\s/i.test(_this.innerHTML))) {
  310. _this.innerHTML = `<img src="${_this.href}" style="max-width: 100%!important;" />`;
  311. }
  312. });
  313. }
  314.  
  315.  
  316. // 快速回复(双击左右两侧空白处)
  317. function quickReply() {
  318. document.getElementById("Wrapper").ondblclick = document.querySelector("#Wrapper > .content").ondblclick = function(event){
  319. if (event.target==this) {
  320. if (document.querySelector('.box.reply-box-sticky')) {
  321. document.getElementById('undock-button').click();
  322. }else{
  323. let _top = document.body.scrollTop + document.documentElement.scrollTop;
  324. document.getElementById('reply_content').focus();
  325. window.scrollTo(0,_top);console.log(_top);
  326. }
  327. }
  328. }
  329. //document.querySelector('div.topic_buttons').insertAdjacentHTML('beforeend', '<a href="javascript:void(0);" id="reply_233" class="tb">快速回复</a>');
  330. /*document.getElementById('reply_233').onclick = function () {
  331. if (document.querySelector('.box.reply-box-sticky')) {
  332. document.getElementById('undock-button').click();
  333. }else{
  334. let _top = document.body.scrollTop + document.documentElement.scrollTop;
  335. document.getElementById('reply_content').focus();
  336. window.scrollTo(0,_top);console.log(_top);
  337. }
  338. }*/
  339. }
  340.  
  341.  
  342. // 新标签页打开链接
  343. function linksBlank(css) {
  344. if (!menu_value('menu_linksBlank')) return
  345. let links = document.querySelectorAll(css);if (!links) return
  346. Array.from(links).forEach(function (_this) {
  347. _this.target = '_blank'
  348. });
  349. }
  350.  
  351.  
  352. // 自动无缝翻页
  353. function pageLoading() {
  354. if (curSite.SiteTypeID > 0){
  355. windowScroll(function (direction, e) {
  356. if (direction === "down") { // 下滑才准备翻页
  357. let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
  358. //console.log(document.documentElement.scrollHeight)
  359. let scrollDelta = curSite.pager.scrollDelta;
  360. if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
  361. if (curSite.pager.type === 1) {
  362. ShowPager.loadMorePage();
  363. }else{
  364. let autopbn = document.querySelector(curSite.pager.nextLink);
  365. if (autopbn){
  366. autopbn.click();
  367. }
  368. }
  369. }
  370. }
  371. });
  372. }
  373. }
  374.  
  375.  
  376. // 滚动条事件
  377. function windowScroll(fn1) {
  378. var beforeScrollTop = document.documentElement.scrollTop,
  379. fn = fn1 || function () {};
  380. setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件
  381. window.addEventListener("scroll", function (e) {
  382. var afterScrollTop = document.documentElement.scrollTop,
  383. delta = afterScrollTop - beforeScrollTop;
  384. if (delta == 0) return false;
  385. fn(delta > 0 ? "down" : "up", e);
  386. beforeScrollTop = afterScrollTop;
  387. }, false);
  388. }, 1000)
  389. }
  390.  
  391.  
  392. var ShowPager = { // 修改自 https://greasyfork.org/scripts/14178
  393. getFullHref: function (e) {
  394. if(e == null) return '';
  395. "string" != typeof e && (e = e.getAttribute("href"));
  396. var t = this.getFullHref.a;
  397. return t || (this.getFullHref.a = t = document.createElement("a")), t.href = e, t.href;
  398. },
  399. createDocumentByString: function (e) {
  400. if (e) {
  401. if ("HTML" !== document.documentElement.nodeName) return (new DOMParser).parseFromString(e, "application/xhtml+xml");
  402. var t;
  403. try {
  404. t = (new DOMParser).parseFromString(e, "text/html");
  405. } catch (e) {
  406. }
  407. if (t) return t;
  408. if (document.implementation.createHTMLDocument) t = document.implementation.createHTMLDocument("ADocument"); else try {
  409. (t = document.cloneNode(!1)).appendChild(t.importNode(document.documentElement, !1)),
  410. t.documentElement.appendChild(t.createElement("head")), t.documentElement.appendChild(t.createElement("body"));
  411. } catch (e) {
  412. }
  413. if (t) {
  414. var r = document.createRange();
  415. r.selectNodeContents(document.body);
  416. var n = r.createContextualFragment(e);
  417. t.body.appendChild(n);
  418. for (var a, o = {
  419. TITLE: !0,
  420. META: !0,
  421. LINK: !0,
  422. STYLE: !0,
  423. BASE: !0
  424. }, i = t.body, s = i.childNodes, c = s.length - 1; c >= 0; c--) o[(a = s[c]).nodeName] && i.removeChild(a);
  425. return t;
  426. }
  427. } else console.error("没有找到要转成DOM的字符串");
  428. },
  429. loadMorePage: function () {
  430. if (curSite.pager) {
  431. let curPageEle = getElementByXpath(curSite.pager.nextLink);
  432. var url = this.getFullHref(curPageEle);
  433. //console.log(`${url} ${curPageEle} ${curSite.pageUrl}`);
  434. if(url === '') return;
  435. if(curSite.pageUrl === url) return;// 不会重复加载相同的页面
  436. curSite.pageUrl = url;
  437. // 读取下一页的数据
  438. curSite.pager.startFilter && curSite.pager.startFilter();
  439. GM_xmlhttpRequest({
  440. url: url,
  441. method: "GET",
  442. timeout: 5000,
  443. onload: function (response) {
  444. try {
  445. var newBody = ShowPager.createDocumentByString(response.responseText);
  446. let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody);
  447. let toElement = getAllElements(curSite.pager.HT_insert[0])[0];
  448. if (pageElems.length >= 0) {
  449. // 如果有插入前函数就执行函数
  450. if (curSite.function && curSite.function.before) {
  451. if (curSite.function.parameter) { // 如果指定了参数
  452. pageElems = curSite.function.before(curSite.function.parameter);
  453. }else{
  454. pageElems = curSite.function.before(pageElems);
  455. }
  456. }
  457. // 插入位置
  458. let addTo;
  459. switch (curSite.pager.HT_insert[1]) {
  460. case 1:
  461. addTo = "beforebegin"
  462. break;
  463. case 2:
  464. addTo = "afterbegin"
  465. break;
  466. case 3:
  467. addTo = "beforeend"
  468. break;
  469. case 4:
  470. addTo = "afterend"
  471. break;
  472. }
  473. // 插入新页面元素
  474. pageElems.forEach(function (one) {
  475. toElement.insertAdjacentElement(addTo, one);
  476. });
  477. // 替换待替换元素
  478. try {
  479. let oriE = getAllElements(curSite.pager.replaceE);
  480. let repE = getAllElements(curSite.pager.replaceE, newBody, newBody);
  481. if (oriE.length === repE.length) {
  482. for (var i = 0; i < oriE.length; i++) {
  483. oriE[i].outerHTML = repE[i].outerHTML;
  484. }
  485. }
  486. } catch (e) {
  487. console.log(e);
  488. }
  489. // 如果有插入后函数就执行函数
  490. if (curSite.function && curSite.function.after) {
  491. if (curSite.function.parameter) { // 如果指定了参数
  492. curSite.function.after(curSite.function.parameter);
  493. }else{
  494. curSite.function.after();
  495. }
  496. }
  497. }
  498. } catch (e) {
  499. console.log(e);
  500. }
  501. }
  502. });
  503. }
  504. },
  505. };
  506.  
  507.  
  508. function getElementByXpath(e, t, r) {
  509. r = r || document, t = t || r;
  510. try {
  511. return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  512. } catch (t) {
  513. return void console.error("无效的xpath");
  514. }
  515. }
  516.  
  517.  
  518. function getAllElements(e, t, r, n, o) {
  519. let getAllElementsByXpath = function(e, t, r) {
  520. return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
  521. }
  522.  
  523. var i, s = [];
  524. if (!e) return s;
  525. if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" == typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) {
  526. return (t || document).querySelectorAll(e);
  527. }(e.slice(4), t) : getAllElementsByXpath(e, t, r); else {
  528. if (!(i = e(r, n, o))) return s;
  529. if (i.nodeType) return s[0] = i, s;
  530. }
  531. return function makeArray(e) {
  532. var t, r, n, o = [];
  533. if (e.pop) {
  534. for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n)));
  535. return a()(o);
  536. }
  537. if (e.item) {
  538. for (t = e.length; t;) o[--t] = e[t];
  539. return o;
  540. }
  541. if (e.iterateNext) {
  542. for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t);
  543. return o;
  544. }
  545. }(i);
  546. }
  547. })();