// ==UserScript==
// @name 模拟LODOP环境
// @namespace http://tampermonkey.net/
// @version 0.1.2
// @description 模拟LODOP虚拟打印机
// @author JC Lee
// @match *://*/*
// @grant none
// @license. MIT
// ==/UserScript==
(function() {
'use strict';
if(window._vue) {
// Your code here...
addMockLODOPButton();
} else {
Object.defineProperty(window, '_vue', {
get: function() {
return window.$$vue;
},
set: function(value) {
addMockLODOPButton();
window.$$vue = value;
}
});
}
function loadStyle(styleContent) {
const style = document.createElement('style');
style.innerHTML = styleContent;
style.type = "text/css";
document.head.append(style);
}
function addMockLODOPButton() {
if(window.LODOP)return;
var button = document.createElement("button");
button.classList.add('dev_tools_button');
button.innerHTML = "模拟虚拟打印机";
loadStyle(`
.dev_tools_button {
width: 130px;
height: 40px;
color: #fff;
border-radius: 5px;
padding: 10px 25px;
font-family: 'Lato', sans-serif;
font-weight: 500;
background: transparent;
cursor: pointer;
transition: all 0.3s ease;
position: relative;
display: inline-block;
box-shadow:inset 2px 2px 2px 0px rgba(255,255,255,.5),
7px 7px 20px 0px rgba(0,0,0,.1),
4px 4px 5px 0px rgba(0,0,0,.1);
outline: none;
position: fixed;
bottom: 30px;
right: 30px;
z-index: 10000000;
}
.dev_tools_button {
background: rgb(0,172,238);
background: linear-gradient(0deg, rgba(0,172,238,1) 0%, rgba(2,126,251,1) 100%);
width: 130px;
height: 40px;
line-height: 42px;
padding: 0;
border: none;
}
.dev_tools_button span {
position: relative;
display: block;
width: 100%;
height: 100%;
}
.dev_tools_button:before,
.dev_tools_button:after {
position: absolute;
content: "";
right: 0;
top: 0;
background: rgba(2,126,251,1);
transition: all 0.3s ease;
}
.dev_tools_button:before {
height: 0%;
width: 2px;
}
.dev_tools_button:after {
width: 0%;
height: 2px;
}
.dev_tools_button:hover{
box-shadow: none;
}
.dev_tools_button:hover:before {
height: 100%;
}
.dev_tools_button:hover:after {
width: 100%;
}
.dev_tools_button span:hover{
color: rgba(2,126,251,1);
}
.dev_tools_button span:before,
.dev_tools_button span:after {
position: absolute;
content: "";
left: 0;
bottom: 0;
background: rgba(2,126,251,1);
transition: all 0.3s ease;
}
.dev_tools_button span:before {
width: 2px;
height: 0%;
}
.dev_tools_button span:after {
width: 0%;
height: 2px;
}
.dev_tools_button span:hover:before {
height: 100%;
}
.dev_tools_button span:hover:after {
width: 100%;
}
`)
button.onclick = function() {
button.parentNode.removeChild(button)
window.LODOP = {
GET_PRINTER_NAME: function() {},
Printers: {
"default": "0",
"list": [
{
"name": "Deli DL-761D",
"DriverName": "Deli DL-761D",
"PortName": "FILE:",
"Orientation": "1",
"PaperSize": "256",
"PaperLength": "1290",
"PaperWidth": "825",
"Copies": "1",
"DefaultSource": "256",
"PrintQuality": "203",
"Color": "1",
"Duplex": "1",
"FormName": "",
"Comment": "",
"DriverVersion": "1794",
"DCOrientation": "90",
"MaxExtentWidth": "840",
"MaxExtentLength": "3000",
"MinExtentWidth": "254",
"MinExtentlength": "50",
"pagelist": [
{
"name": "USER"
},
{
"name": "2 x 4"
}
],
"subdevlist": []
}
]
}
}
};
document.body.appendChild(button);
}
})();