没有合适的资源?快使用搜索试试~ 我知道了~
本文实例讲述了基于Python开发chrome插件的方法。分享给大家供大家参考,具体如下: 谷歌Chrome插件是使用HTML、JavaScript和CSS编写的。如果你之前从来没有写过Chrome插件,我建议你读一下这个。在这篇教程中,我们将教你如何使用Python代替JavaScript。 创建一个谷歌Chrome插件 首先,我们必须创建一个清单文件:manifest.json。 { "manifest_version": 2, "name": "Python Chrome Plugin", "description": "This extension runs Python co
资源详情
资源评论
资源推荐
基于基于Python开发开发chrome插件的方法分析插件的方法分析
本文实例讲述了基于Python开发chrome插件的方法。分享给大家供大家参考,具体如下:
谷歌Chrome插件是使用HTML、JavaScript和CSS编写的。如果你之前从来没有写过Chrome插件,我建议你读一下这个。在这篇教程中,我
们将教你如何使用Python代替JavaScript。
创建一个谷歌创建一个谷歌Chrome插件插件
首先,我们必须创建一个清单文件:manifest.json。
{
"manifest_version": 2,
"name": "Python Chrome Plugin",
"description": "This extension runs Python code.",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"activeTab",
"https://ajax.googleapis.com/"
] }
然后创建一个名为popup.html的文件:
<!doctype html>
<!--
This page is shown when the extension button is clicked, because the
"browser_action" field in manifest.json contains the "default_popup" key with
value "popup.html".
-->
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
#status {
/* avoid an excessively wide status text */
white-space: pre;
text-overflow: ellipsis;
overflow: hidden;
max-width: 400px;
}
</style>
<!--
- JavaScript and HTML must be in separate files: see our Content Security
- Policy documentation[1] for details and explanation.
-
- [1]: https://developer.chrome.com/extensions/contentSecurityPolicy
-->
<script src="popup.js"></script>
</head>
<body>
<div id="status"></div>
<img id="image-result" hidden>
</body>
</html>
最后得到一个图标,并保存为icon.png。打开chrome://extensions,点击开发者模式。点击“加载未打包扩展程序”,选择文件夹,点击OK。
为为Chrome扩展程序添加扩展程序添加Python
现在你拥有了最基本的权利,我们可以在代码中添加Python。为了能在一个浏览器中运行Python,你有很多个选择,包括Brython和
emcascripten。我们决定使用Brython。我们将从一个服务器运行Brython脚本。改变popup.html的内容:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta charset="iso-8859-1">
<style>
body {
margin: 0 !important;
padding: 0 !important;
width: 800;
}
#frame {
overflow: hidden;
width:790;
height:324;
}
weixin_38609693
- 粉丝: 8
- 资源: 961
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0