Roll20 Character Sheet Print Support

Adds Print support to character sheet pop-ups on Roll20.net

À partir de 2020-03-07. Voir la dernière version.

// ==UserScript==
// @name			Roll20 Character Sheet Print Support
// @namespace		http://statonions.com
// @version			0.1.4
// @description		Adds Print support to character sheet pop-ups on Roll20.net
// @author			Justice Noon
// @match			https://app.roll20.net/editor/
// ==/UserScript==
// Changelog: Cleaned up so warnings don't display anymore. Increased timeout, stopped assuming underscore will be fully loaded. Increased compatibility with other scripts and extensions (VTTES)
(function() {
var areYouReady = function(times) {
    /* globals _, Campaign, charactersheet_useroptions */
	if (times > 20) {
		return; }
	if (typeof Campaign == 'undefined' || !Campaign.gameFullyLoaded) {
		setTimeout(areYouReady, 5000, times++);
		return;
	}
	if (!document.getElementById('printCss')) {
		var newBase = '', oldBase = _.find(document.styleSheets, o => o.href && o.href.indexOf('base.css') > -1);
        for (var k in oldBase.rules) {
            if (oldBase.rules[k].conditionText != 'print') {
                newBase += oldBase.rules[k].cssText;
            }
        }
        document.querySelector('link[href*=base]').remove();
		var insert = document.createElement('style'), baseStyle = document.createElement('style');
		insert.setAttribute('type', 'text/css'); insert.setAttribute('media', 'print'); insert.setAttribute('id', 'printCss');
		insert.innerHTML = newCss;
        if (typeof charactersheet_useroptions != 'undefined' && charactersheet_useroptions[0].attribute == 'is_v1' && charactersheet_useroptions[1].attribute == 'migrate1') {
            insert.innerHTML += pfcCss; }
		baseStyle.setAttribute('type', 'text/css');
		baseStyle.innerHTML = newBase;
		document.getElementsByTagName('head')[0].insertBefore(baseStyle, document.querySelector('head>link'));
		document.getElementsByTagName('head')[0].appendChild(insert);
	}
};
setTimeout(areYouReady, 1);
var newCss =
`body>* {
        display: none!important;
  }

  .charactersheet,
    .ui-dialog,
    .ui-dialog-content
  {
    height: auto!important;
    display: block!important;
  }

  .ui-dialog
  {
    overflow: visible!important;
    position: relative!important;
    width: 100%!important;
    left: 0!important;
    top: 0!important;
    background-color: #fff;
    border-width: 0;
  }

  #editobject,
    #floatingtoolbar,
    #footer,
    #page-toolbar,
    .nav.nav-tabs,
    .ui-dialog-titlebar,
    .ui-resizable-handle
  {
    display: none!important;
  }

  body
  {
    overflow: visible;
    background: #fff;
  }
`;
var pfcCss =
`.sheet-h2-section,.sheet-section:not(.sheet-section1) {
    page-break-inside: avoid;
}
.sheet-top-buttons,sheet-main:not(.sheet-section),.sheet-mode,.sheet-selectedlabel-check,.sheet-selectedlabel-check+b,.sheet-showsect {
	display: none!important;
}`;
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。