伪·转换贴吧 ed2k 链接

将贴吧里提醒“贴吧安卓客户端可直接观看影片”的 ed2k 链接转换为可点击下载的链接……

< Feedback on 伪·转换贴吧 ed2k 链接

Review: OK - script works, but could use improvement

§
Posted: 2014-06-14
帖子翻页的话会失效

BTW,准备用下你的代码
864907600ccAuthor
§
Posted: 2014-06-16
实际上这不是个例,贴吧使用了 ajax 翻页,可能会导致很多脚本都用不了,目前还没有打算修复的计划,抱歉了
§
Posted: 2014-06-16
Edited: 2014-06-16
简单修改了下,未实际测试,你可以试试。
function run() {
    var x=document.getElementsByClassName('j_d_post_yingyin_url');
    for(var i=0;i<x.length;i++){
        if (x[i].hasAttribute('gm_checked')) {
            continue;
        }
        x[i].outerHTML=x[i].outerHTML.replace('<span','<a').replace('</span','</a');
        x[i].setAttribute('href',x[i].innerHTML);
        x[i].setAttribute('gm_checked', 'true');
    }
}

function addMutationObserver(selector, callback) {
    var watch = document.querySelector(selector);
    if (!watch) return;

    var observer = new MutationObserver(function(mutations){
        var nodeAdded = mutations.some(function(x){ return x.addedNodes.length > 0; });
        if (nodeAdded) {
            // observer.disconnect();
            callback();
        }
    });
    observer.observe(watch, {childList: true, subtree: true});
}

run();

addMutationObserver('body', run);
§
Posted: 2014-06-19
简单修改了下,未实际测试,你可以试试。
function run() {
    var x=document.getElementsByClassName('j_d_post_yingyin_url');
    for(var i=0;i<x.length;i++){
        if (x[i].hasAttribute('gm_checked')) {
            continue;
        }
        x[i].outerHTML=x[i].outerHTML.replace('<span','<a').replace('</span','</a');
        x[i].setAttribute('href',x[i].innerHTML);
        x[i].setAttribute('gm_checked', 'true');
    }
}

function addMutationObserver(selector, callback) {
    var watch = document.querySelector(selector);
    if (!watch) return;

    var observer = new MutationObserver(function(mutations){
        var nodeAdded = mutations.some(function(x){ return x.addedNodes.length > 0; });
        if (nodeAdded) {
            // observer.disconnect();
            callback();
        }
    });
    observer.observe(watch, {childList: true, subtree: true});
}

run();

addMutationObserver('body', run);
thanks

Post reply

Sign in to post a reply.