在PDF页面上运行Chrome插件 [英] Run a Chrome Plugin On a PDF Page

查看:85
本文介绍了在PDF页面上运行Chrome插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要使用Chrome扩展程序:

Using a Chrome extension, I'd like to:

  1. 检测当前选项卡是否已加载PDF文件.
  2. 在popup.html中添加一个按钮,以将PDF转换为HTML5.
  3. 获取PDF文件的URL,并将其发送到在线服务.

要完成第一项,我认为此页面上的一种解决方案可以起作用:如何检测Google Chrome扩展程序中当前选项卡的mime类型?

To accomplish #1, I think one of the solutions on this page could work: How can I detect the current tab's mime type in a Google Chrome extension?

问题是我无法让扩展程序在PDF页面本身上运行.

The problem is that I'm having trouble getting the extension to run on the PDF page itself.

如何在PDF页面上运行扩展名的 background.js ?

How do I run background.js of the extension on the PDF page?

当前我的清单文件:

{
   "matches":[
      "https://*/*",
      "http://*/*"
   ],
   "run_at":"document_idle",
   "css":[
      "jquery-ui.css",
      "resizable.css"
   ],
   "js":[
      "jquery.js",
      "jquery-ui.js",
      "storage.js",
      "background.js"
   ],
   "all_frames":true
}

推荐答案

在清单文件中,您应该具有以下内容:

In the manifest file you should have this:

"content_scripts": [
 {
   "matches": ["*://*.pdf"],
   "js": ["background.js"]
 }
]

这篇关于在PDF页面上运行Chrome插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆