// ==UserScript== // @name getzhidaofile // @namespace http://userscripts.org/scripts/show/176807 // @description 获取百度知道附件下载地址 // @author wellblink // @version 1.0.10.11 // @include http://zhidao.baidu.com/question/* // @grant none // @run-at document-end // @downloadURL none // ==/UserScript== var gd, gd0, gd1, gd2, i, j, tmp; gd0 = document.getElementsByTagName('div'); gd = new Array(); for (i = 0; i < gd0.length; i++) { if (gd0[i].id && (gd0[i].id.substring(0, 15) == 'answer-content-' || gd0[i].id.substring(0, 18) == 'recommend-content-' || gd0[i].id.substring(0, 13) == 'best-content-')) gd.push(gd0[i]); } gd2 = new Array(); gd0 = '['; for (i = 0; i < gd.length; i++) { gd1 = gd[i].getElementsByTagName('file'); for (j = 0; j < gd.length; j++) { gd0 += '{\'' + gd1[j].getAttribute('name') + '\':\'' + gd1[j].getAttribute('link') + '\'}'; } } gd0 += ']'; if (gd0.length > 9) { gd2 = eval(gd0); waitload(); } function waitload() { if (document.readyState != 'complete') return setTimeout(waitload, 1000); var gda, a, tmp1, tmp2, tmp3; for (var i = 0; i < gd.length; i++) { gda = gd[i].querySelector('.file-inner'); for (a in gd2[i]) { try { tmp2 = gda.querySelector('.i-file-down').parentNode; tmp2.outerHTML = '