chrome extension demos

demo

https://github.com/hartleybrody/buzzkill/blob/master/bootstrap.js

https://github.com/hartleybrody/buzzkill/blob/master/manifest.json

  1. // when the extension is first installed
  2. chrome.runtime.onInstalled.addListener(function(details) {
  3. chrome.storage.sync.set({ clean_news_feed: true });
  4. });
  5. // listen for any changes to the URL of any tab.
  6. chrome.tabs.onUpdated.addListener(function(id, info, tab) {
  7. if (tab.url.toLowerCase().indexOf("facebook.com") > -1) {
  8. chrome.pageAction.show(tab.id);
  9. }
  10. });
  11. // update the icon when the user's settings change
  12. // chrome.storage.onChanged.addListener(function(changes, areaName){
  13. // alert("changed settings");
  14. // console.log("changed settings");
  15. // if (localStorage["clean_news_feed"] == "true"){
  16. // path = "active-icon.jpeg";
  17. // } else {
  18. // path = "inactive-icon.jpeg";
  19. // }
  20. // chrome.tabs.getCurrent( function(tab){
  21. // chrome.pageAction.setIcon({
  22. // "tabId": tab.id,
  23. // "path": path
  24. // });
  25. // });
  26. // });
  1. chrome.runtime.onInstalled.addListener(function() {
  2. chrome.contextMenus.create({
  3. id: "sampleContextMenu",
  4. title: "Sample Context Menu",
  5. contexts: ["selection"]
  6. });
  7. });
  1. chrome.runtime.onInstalled.addListener(function() {
  2. chrome.contextMenus.create({
  3. id: "sampleContextMenu",
  4. title: "Sample Context Menu",
  5. contexts: ["selection"]
  6. });
  7. });
  8. // This will run when a bookmark is created.
  9. chrome.bookmarks.onCreated.addListener(function() {
  10. // do something
  11. });
  12. chrome.runtime.onMessage.addListener(function(message, sender, reply) {
  13. chrome.runtime.onMessage.removeListener(event);
  14. });
  1. //

content script


  1. chrome.runtime.onMessage.addListener(
  2. function(message, callback) {
  3. if (message == changeColor”){
  4. chrome.tabs.executeScript({
  5. code: 'document.body.style.backgroundColor="orange"'
  6. });
  7. }
  8. });
  1. chrome.runtime.onMessage.addListener(
  2. function(message, callback) {
  3. if (message == runContentScript”){
  4. chrome.tabs.executeScript({
  5. file: 'contentScript.js'
  6. });
  7. }
  8. });

github jira chrome extensions

https://github.com/RobQuistNL/chrome-github-jira/blob/master/src/options.js

  1. chrome.storage.sync.get({}, function() {
  2. //
  3. });
  4. chrome.storage.sync.set({}, function() {
  5. //
  6. });
  7. chrome.storage.sync.remove(['jiraUrl', 'prTemplate']);

https://github.com/maxday/jira-issue-easyCopy/blob/master/content.js


  1. chrome.runtime.onMessage.addListener(function(msg, sender, sendResponse) {
  2. var issueNumber = document.getElementById("key-val").textContent;
  3. var issueDescription = document.getElementById("summary-val").textContent;
  4. sendResponse(issueNumber + " - " + issueDescription);
  5. });

https://github.com/maxday/jira-issue-easyCopy/blob/master/background.js


  1. chrome.browserAction.onClicked.addListener(function(tab) {
  2. chrome.tabs.sendMessage(tab.id, { text: "report_back" }, sendToClipbord);
  3. });
  4. function sendToClipbord(myString) {
  5. var input = document.createElement('textarea');
  6. document.body.appendChild(input);
  7. input.value = myString;
  8. input.focus();
  9. input.select();
  10. document.execCommand('Copy');
  11. input.remove();
  12. }

https://github.com/taylorfoss89/Jira-Chrome-Extension/blob/master/jiraExtension/popup.js

  1. chrome.tabs.update({
  2. url: "https://contegixapp1.livenation.com/jira/browse/" + jiraGroup + '-' + jiraNumber
  3. });

https://github.com/hbmartin/chrome-jira/blob/master/background.js

  1. chrome.browserAction.setBadgeText({text: count.toString()});
  2. chrome.browserAction.setBadgeBackgroundColor({color: [20, 20, 20, 230]});
  3. chrome.windows.getAll({populate:true}, function(winData) {
  4. //
  5. });
  6. // Handle Jira keyword in omnibox
  7. chrome.omnibox.onInputEntered.addListener(function(text) {
  8. chrome.tabs.getSelected(null, function(tab) {
  9. chrome.tabs.update(tab.id, {
  10. url: jira_url + "/secure/QuickSearch.jspa?searchString=" + text
  11. });
  12. });
  13. });
  14. chrome.extension.onMessage.addListener(function(msg,sender,sendResponse){
  15. if (msg == "updateJira"){
  16. console.log("async update");
  17. setTimeout(updateJira, 2);
  18. }
  19. });

https://github.com/hbmartin/chrome-jira/blob/master/common.js

https://github.com/hbmartin/chrome-jira/blob/master/manifest.json

https://github.com/hbmartin/chrome-jira/blob/master/options.js

  1. chrome.extension.sendMessage("updateJira");

https://github.com/hbmartin/chrome-jira/blob/master/popup.js

  1. chrome.extension.getBackgroundPage().updateJira();
  2. window.open(chrome.extension.getURL("options.html"));
  3. chrome.extension.sendMessage("updateJira");

https://github.com/joshuaheng/jira-github-chrome/blob/master/background.js

  1. chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
  2. if (info.status == "complete") {
  3. chrome.tabs.executeScript(tabId, {file: 'content.js'});
  4. }
  5. });

https://github.com/joshuaheng/jira-github-chrome/blob/master/content.js


  1. (() => {
  2. const $title = document.querySelector('.js-issue-title');
  3. if (!$title) {
  4. return;
  5. }
  6. chrome.storage.local.get(['jiraUrl', 'inlineLinks'], (options) => {
  7. const jiraUrl = !!options.jiraUrl ?
  8. options.jiraUrl :
  9. 'https://jira.nextcapital.com';
  10. let title = $title.innerHTML.replace(/(<a[^>]+>|⬆︎|<\/a>)/g, '');
  11. title.match(/[a-zA-Z0-9-]+(?=[\],\s\d#]*\])/g).forEach((tag) => {
  12. const url = `${jiraUrl}/browse/${tag}`;
  13. const attrs = `href="${url}" target="_blank"`;
  14. const replacement = options.inlineLinks === false ?
  15. `${tag}<a ${attrs}>⬆︎</a>` :
  16. `<a ${attrs}>${tag}</a>`;
  17. title = title.replace(tag, replacement);
  18. });
  19. $title.innerHTML = title;
  20. });
  21. })();

https://github.com/joshuaheng/jira-github-chrome/blob/master/options.js


  1. const $jiraUrlInput = document.querySelector('#jira-url');
  2. const $inlineLinksInput = document.querySelector('#inline-links');
  3. chrome.storage.local.get(['jiraUrl', 'inlineLinks'], (options) => {
  4. if (!!options.jiraUrl) {
  5. $jiraUrlInput.value = options.jiraUrl;
  6. }
  7. if (options.inlineLinks !== false) {
  8. $inlineLinksInput.setAttribute('checked', 'checked');
  9. }
  10. });
  11. $jiraUrlInput.addEventListener('change', () => {
  12. chrome.storage.local.set({ jiraUrl: $jiraUrlInput.value });
  13. });
  14. $inlineLinksInput.addEventListener('change', () => {
  15. chrome.storage.local.set({ inlineLinks: $inlineLinksInput.checked });
  16. });

chrome extension demos的更多相关文章

  1. Chrome Extension 检查视图(无效)处理方法

    最近闲来无事,简单看了下Chrome扩展的开发,并且开发一个小小的翻译插件(TranslateBao)作为练手,开发细节不详述了,如果有新学习chrome extension开发的新人,可以参考源码, ...

  2. 开发Chrome Extension截取你微博的帐号密码

    Google允许开发者对Chrome浏览器做扩展,所以有了之前火爆的12306抢票软件,我 也用它抢过票,一直很好奇它怎么注入js到12306上面的.这周有空研究了下Chrome Extension, ...

  3. chrome extension overview

    目录 什么是扩展............................................................................................ ...

  4. 打包Egret游戏为Chrome extension

    今天,本来是打算做一个Chrome扩展去爬取网站base64编码图片的. 在跟着图灵社区<Chrome扩展及应用开发>敲demo代码的过程中,发现chrome的扩展的结构理论上可以兼容所有 ...

  5. Google Chrome Native Messaging开发实录(二)Chrome Extension扩展

    接上一篇<Google Chrome Native Messaging开发实录(一)背景介绍>的项目背景,话不多说,有关Chrome Extension介绍和文档就不展开了,直接上代码. ...

  6. Chrome Extension 实战

    想起个问题,线上项目js要有bug,怎么进行调试修改. ------------- 想起来,方法应该是,拦截线上的js的请求,转到本地代码上进行调试... ------------- 网上看到 Chr ...

  7. 解决chrome extension无法下载的问题

    由于GFW把谷歌应用商店给屏蔽了,下载chrome扩展变得很困难. 我使用的是版本30.0.1599.101 m. 那么你需要做的第一个处理是,修改host文件,保证chrome应用商店可以登录.如下 ...

  8. 一起来做Chrome Extension《搭个架子》

    CEF - A simple Chrome Extension development falsework CEF是一个简单的Chrome Extension开发脚手架,它有如下功能: 模块化的结构, ...

  9. 一起来做Chrome Extension《一些问题》

    目录 Unchecked runtime.lastError: The message port closed before a response wa received. 使用 eval Conte ...

随机推荐

  1. 从零开始一个http服务器(一)-开始

    从零开始一个http服务器 (一) 代码地址 : https://github.com/flamedancer/cserver git checkout step1 一个简单的socket serve ...

  2. BZOJ1011 莫比乌斯反演(基础题

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1101 [题目大意] 求[1,n][1,m]内gcd=k的情况 [题解] 考虑求[1,n ...

  3. HashMap底层实现原理及扩容机制

    HashMap的数据结构:数组+链表+红黑树:Java7中的HashMap只由数组+链表构成:Java8引入了红黑树,提高了HashMap的性能:借鉴一张图来说明,原文:https://www.jia ...

  4. JavaWeb——升级赛-学生成绩管理系统(2).java---19.01.03

    dao.java package Dao; import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLExcept ...

  5. 滑雪_KEY

    滑雪 ( skiing.pas/c/cpp) [题目描述] MM 参加一个滑雪比赛,滑雪场是一个 N×M 的矩形, MM 要从起点( 1, 1)滑到( N,M).矩形中每个单位格子有一个海拔高度值 h ...

  6. 北京Uber优步司机奖励政策(12月31日)

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  7. 笔记本ubuntu安装wifi驱动(未完成)

    1. 用联想E440,Ubuntu14.04,安装完之后,没有检查到wifi的驱动,所以需要安装.

  8. Machine Learning Basic Knowledge

    常用的数据挖掘&机器学习知识(点) Basis(基础): MSE(MeanSquare Error 均方误差),LMS(Least MeanSquare 最小均方),LSM(Least Squ ...

  9. OSG-粒子系统和初步

    本文转至http://www.cnblogs.com/shapherd/archive/2010/08/10/osg.html 作者写的比较好,再次收藏,希望更多的人可以看到这个文章 互联网是是一个相 ...

  10. 第四篇 与Flask相关的插件(flask-session、wtforms)

    公司中使用SQL的种方式: 1. 写Django:ORM(关系对象映射), 2. 写Flask和其他:有两种方式: (1) 原生SQL:使用原生SQL有两种选择: A. pymysql (python ...