模拟LODOP环境

模拟LODOP虚拟打印机

当前为 2023-04-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         模拟LODOP环境
// @namespace    http://tampermonkey.net/
// @version      0.1
// @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', {
            set: function(value) {
                addMockLODOPButton();
            }
        });
    }

    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() {
            console.log(window)
            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);
    }
})();