// ==UserScript== // @name OFD预览 // @namespace http://tampermonkey.net/ // @version 0.2 // @description try to take over the world! // @author You // @match http://*.zhbg.kjt.gx.gov/* // @grant none // @run-at context-menu // ==/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)}) } } //查找加载ofd失败后生成的div if (!document.querySelector('embed[type="application/ofd"] ')){ throw new Error('Whoops!')} document.querySelector('embed[type="application/ofd"] ').style.visibility = 'hidden'; //查找ofd文件的标识 var attachGuid = findVue(document.querySelector("div#OFD").parentNode.parentNode).attachguid; if (!attachGuid){ throw new Error('Whoops!')} window.open('http://sxqp.zhbgzt.gx.gov/login.html?' + attachGuid, ""); })();