Greasy Fork

Comprovante PagSeguro

O PagSeguro devia ter vergonha de não oferecer suporte a impressora térmica

当前为 2018-09-06 提交的版本,查看 最新版本

// ==UserScript==
// @name Comprovante PagSeguro
// @namespace http://fcmartins.com.br
// @description O PagSeguro devia ter vergonha de não oferecer suporte a impressora térmica
// @version 1
// @include https://pagseguro.uol.com.br/transaction/details/receipt.jhtml?id=*
// @run-at document-idle

// ==/UserScript==

let h2 = document.querySelector("h2");
h2.parentNode.removeChild(h2);

let receipt = document.querySelector("div.receipt-model");

let figure = receipt.querySelector("figure");
figure.parentNode.removeChild(figure);

let li = receipt.querySelector("span#nsu").parentNode;
li.parentNode.removeChild(li);

li = receipt.querySelector("span#cv").parentNode;
li.parentNode.removeChild(li);

li = receipt.querySelector("span#arqc").parentNode;
li.parentNode.removeChild(li);

li = receipt.querySelector("span#aid").parentNode;
li.parentNode.removeChild(li);

Array.from(receipt.querySelectorAll("hr")).forEach(el => el.parentNode.removeChild(el));

let ul = receipt.querySelector("ul:last-of-type");
ul.parentNode.removeChild(ul);

let section = document.querySelector("section");
section.parentNode.removeChild(section);

let div = document.querySelector("div#cboxOverlay");
div.parentNode.removeChild(div);

div = document.querySelector("div#colorbox");
div.parentNode.removeChild(div);

div = document.querySelector("div.receipt-model-tools");
div.parentNode.removeChild(div);

Array.from(document.querySelectorAll("[style]")).forEach(el => el.removeAttribute('style'));

Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]")).forEach(el => el.parentNode.removeChild(el));

Array.from(document.querySelectorAll("style")).forEach(el => el.parentNode.removeChild(el));

let head = document.head;
if(head) {
	let style = document.createElement("style");
	style.setAttribute("type", "text/css");
	style.textContent = "body.80 {width: 80mm;} body.57 {width: 57mm} body {font-family: monospace; font-size: 10pt;} div {background-color: rgb(250, 235, 215); padding: 5mm;} ul {padding: 0;} li {list-style-type: none; font-family: monospace; font-size: 10pt;}";
	head.appendChild(style);
  
  style = document.createElement("style");
	style.setAttribute("type", "text/css");
  style.setAttribute("media", "print");
	style.textContent = "div {background-color: rgb(255, 255, 255); border-bottom-style: dashed; border-bottom-width: 1px;}";
	head.appendChild(style);
}

window.print();