Greasy Fork

调整打印文件

2022/8/3 08:33:33

当前为 2022-08-05 提交的版本,查看 最新版本

// ==UserScript==
// @name        调整打印文件
// @namespace   print adjust
// @match       https://ctbpsp.com/#/bulletinDetail?uuid=*
// @match       https://bulletin.cebpubservice.com/qualifyBulletin/*
// @match       https://bulletin.cebpubservice.com/biddingBulletin/*
// @match       https://bulletin.cebpubservice.com/candidateBulletin/*
// @match       https://bulletin.cebpubservice.com/resultBulletin/*
// @run-at      document-end
// @grant       unsafeWindow
// @version     1.2.2
// @author      我爱小熊啊
// @description 2022/8/3 08:33:33
// @description cebpubservice.com 文件加载时间较长,遇到未加载完成的,页码输入界面点击取消,文件加载完后,记住页码,刷新输入页码,等待加载完成
// @description 将 ctbpsp.com 与 cebpubservice.com 的等待时间做区分
// @description 自动隐藏 cebpubservice.com 上的二维码广告
// @description 增加对 cebpubservice.com的支持
// @description 中国招标投标公共服务平台公告文件打印调整
// @license     MIT
// ==/UserScript==

// 设置延时定时器,避免网页未加载完,弹出页码输入框
setTimeout(function(){
  var weburl = window.location.href;
  var n = 1;
  // ctbpsp.com 网页打印
  if(weburl.indexOf('ctbpsp.com')!=-1){
    // var windowAttribute = $('iframe');  ??? 引入 jQuery 库也不生效
    var windowAttribute = document.getElementsByTagName('iframe')[0];
    n = prompt('请输入文件页码','');
   if(n){    // 如果输入框点击取消,则 prompt 返回的是 null,则取消更改,否则网页会出错
     windowAttribute.width = 900;
     windowAttribute.height = 1150 * n;
     // alert("Hello");
   }
  }
  
  // cebpubservice.com 网页打印
  if(weburl.indexOf('cebpubservice.com')!=-1){
    setTimeout(function(){
      var p = document.getElementsByClassName('pdf_wraper')[0];
      var b = document.getElementsByClassName('PublicAddress')[0];
      b.style.display = 'none';
      // var n = prompt('请输入文件页码','');
      n = prompt('请输入文件页码','');
      if(n){
        p.style.width = '900px';
        var h = n * 1150;
        var gaodu = h + 'px';
        p.style.height = gaodu;
      }
    }, 6000);
  }
}, 3000);

// window.onload = function () {
//     // 加载时获取
//     var a = document.getElementsByTagName('select')[0];
//     console.info(a);
// }