mivalsten / ddb-dm-screen

MIT License
30 stars 10 forks source link

V2.0 full scrape #20

Closed mivalsten closed 5 years ago

mivalsten commented 5 years ago

This is total overhaul of the userscript, completely removing JSON and relying on statistics computed by ddb character sheet.

tbbstny commented 5 years ago

Just FYI - I've got a Firbolg (from VGtM) Ranger that isn't showing correctly in this version. All my other players are from PH, and looking great.

mivalsten commented 5 years ago

@tbbstny What is the exact issue?

tbbstny commented 5 years ago

Seems to be intermittent, perhaps the issue w/ too many accesses via iframes. Sometimes I'll get stats, other times I don't and all the following (HP, AC, Perceptions) show values of NaN.

Have you considered simply tiling the iFrames and using them directly? The script to do that is super simple...

// ==UserScript==
// @name         ddb-dm-screen-3
// @namespace    https://github.com/mivalsten/ddb-dm-screen
// @version      2.0.2
// @description  Poor man's DM screen for DDB campaigns
// @author       You
// @match        https://www.dndbeyond.com/campaigns/*
// @grant        none
// ==/UserScript==
//
var $ = window.jQuery;

(function() {
    $('.ddb-campaigns-character-card-footer-links-item-view').each(function(index, value) {
        let node = $(this);

        // Remove existing header info in preference of iFrame header
        let card = node.closest('.ddb-campaigns-character-card');
        card.find('.ddb-campaigns-character-card-header-upper-portrait').remove();
        card.find('.ddb-campaigns-character-card-header-upper-character-info-primary').remove();
        card.find('.ddb-campaigns-character-card-header-upper-character-info-secondary').first().remove();

        //.ddb-campaigns-character-card-header padding 20px

        if (!node.parents().hasClass('ddb-campaigns-detail-body-listing-inactive')) {
            card.find('.ddb-campaigns-character-card-header').after(`<iframe src="${node.attr('href')}" style="width: 100%; height: 550px"></iframe>`);
        }
    });
})();