OFD预览
// ==UserScript==
// @name OFD预览
// @namespace http://tampermonkey.net/
// @version 0.6
// @description try to take over the world!
// @author You
// @match http://*.zhbg.kjt.gx.gov/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function() {
'use strict';
function findVue(el){
var child = [window._Vue];
while (child.length > 0){
var n = child.pop();
if(n.$el === el){
return n;
}
n.$children.forEach(function(i){child.push(i)})
}
}
function DownloadOfd(){
//查找下载按钮并转换成Vue对象
let b = document.querySelector(".main>.main-header>.el-button.el-button--primary");
let v = findVue(b);
//获取下载文件的guid
var attachGuid =v.$parent.attachguid;
if (!attachGuid){ throw new Error('未找到下载文件的guid!')}
//使用移动版本的下载功能,可以下载未加密的文件
window.open('http://sxqp.zhbgzt.gx.gov/login.html?' + attachGuid, "");
}
// 创建下载预览文件文件按钮元素
const floatingButton = document.createElement('button');
// 设置按钮的文本内容
floatingButton.textContent = '下载预览文件';
// 设置按钮的样式
floatingButton.style.position = 'fixed';
floatingButton.style.bottom = '100px';
floatingButton.style.right = '20px';
//floatingButton.style.backgroundColor = '#007BFF';
//floatingButton.style.color = 'white';
//floatingButton.style.padding = '10px 20px';
//floatingButton.style.border = 'none';
//floatingButton.style.borderRadius = '5px';
floatingButton.style.cursor = 'pointer';
floatingButton.style.zIndex = '9999';
// 为按钮添加点击事件监听器
floatingButton.addEventListener('click', DownloadOfd);
// 将按钮添加到页面的 body 元素中
document.body.appendChild(floatingButton);
})();