chrome extension demos

时间:2021-07-17 17:50:48

chrome extension demos

demo

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

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

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

content script


chrome.runtime.onMessage.addListener(
function(message, callback) {
if (message == “changeColor”){
chrome.tabs.executeScript({
code: 'document.body.style.backgroundColor="orange"'
});
}
});
  chrome.runtime.onMessage.addListener(
function(message, callback) {
if (message == “runContentScript”){
chrome.tabs.executeScript({
file: 'contentScript.js'
});
}
});

github jira chrome extensions

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

chrome.storage.sync.get({}, function() {
//
});
chrome.storage.sync.set({}, function() {
//
}); chrome.storage.sync.remove(['jiraUrl', 'prTemplate']);

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


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

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


chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.sendMessage(tab.id, { text: "report_back" }, sendToClipbord);
}); function sendToClipbord(myString) {
var input = document.createElement('textarea');
document.body.appendChild(input);
input.value = myString;
input.focus();
input.select();
document.execCommand('Copy');
input.remove();
}

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

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

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

chrome.browserAction.setBadgeText({text: count.toString()});

chrome.browserAction.setBadgeBackgroundColor({color: [20, 20, 20, 230]}); 

chrome.windows.getAll({populate:true}, function(winData) {
//
}); // Handle Jira keyword in omnibox
chrome.omnibox.onInputEntered.addListener(function(text) {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.update(tab.id, {
url: jira_url + "/secure/QuickSearch.jspa?searchString=" + text
});
});
}); chrome.extension.onMessage.addListener(function(msg,sender,sendResponse){
if (msg == "updateJira"){
console.log("async update");
setTimeout(updateJira, 2);
}
});

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

chrome.extension.sendMessage("updateJira");

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

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

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

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

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


(() => {
const $title = document.querySelector('.js-issue-title');
if (!$title) {
return;
} chrome.storage.local.get(['jiraUrl', 'inlineLinks'], (options) => {
const jiraUrl = !!options.jiraUrl ?
options.jiraUrl :
'https://jira.nextcapital.com'; let title = $title.innerHTML.replace(/(<a[^>]+>|⬆︎|<\/a>)/g, ''); title.match(/[a-zA-Z0-9-]+(?=[\],\s\d#]*\])/g).forEach((tag) => {
const url = `${jiraUrl}/browse/${tag}`;
const attrs = `href="${url}" target="_blank"`; const replacement = options.inlineLinks === false ?
`${tag}<a ${attrs}>⬆︎</a>` :
`<a ${attrs}>${tag}</a>`; title = title.replace(tag, replacement);
}); $title.innerHTML = title;
});
})();

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


const $jiraUrlInput = document.querySelector('#jira-url');
const $inlineLinksInput = document.querySelector('#inline-links'); chrome.storage.local.get(['jiraUrl', 'inlineLinks'], (options) => {
if (!!options.jiraUrl) {
$jiraUrlInput.value = options.jiraUrl;
} if (options.inlineLinks !== false) {
$inlineLinksInput.setAttribute('checked', 'checked');
}
}); $jiraUrlInput.addEventListener('change', () => {
chrome.storage.local.set({ jiraUrl: $jiraUrlInput.value });
}); $inlineLinksInput.addEventListener('change', () => {
chrome.storage.local.set({ inlineLinks: $inlineLinksInput.checked });
});

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. google全球地址大全

    https://github.com/justjavac/Google-IPs http://www.aol.com/依托于google的一个搜索,通过这个搜索

  2. 微信朋友圈如何同时分享&lpar;图片&plus;文字&rpar; Android版

    以下是:微信朋友圈SDK 分享图片的代码,但只能分享图片,不能分享文字,如何才能图片和文字同时分享?求各位大神指教! public class MainActivity extends Activit ...

  3. &lbrack;2012山东省第三届ACM大学生程序设计竞赛&rsqb;——n a&Hat;o7 &excl;

    n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...

  4. Static关键字的作用及使用

    1.使用static声明属性 如果希望一个属性被所有对象共同拥有,可以将其声明为static类型. 声明为static类型的属性或方法,此属性或方法也被称为类方法,可以由类名直接调用. class P ...

  5. MVC Code First &lpar;代码优先&rpar;

    首先配置web.config <connectionStrings> <add name="BookDbContext" connectionString=&qu ...

  6. mysql中You can&&num;39&semi;t specify target table for update in FROM clause

    使用mysql在删除表中重复记录 delete from user where username in (select user name form(select username from user ...

  7. 64位平台C&sol;C&plus;&plus;容易犯的错误

     64位平台的介绍 IA-64 is a 64-bit microprocessor architecture developed by Intel and Hewlett Packard compa ...

  8. Shell and DOS

    long long ago 自己便想总结下shell命令以及dos常用的命令,毕竟实际实践中会经常用到,用的好的批处理或者shell脚本会事半功倍,好了,废话不多说,开始. shell echo [字 ...

  9. 实现数据结构与算法需要掌握的C语言

    我使用C语言并不频繁,一般都是用来实现数据结构与算法,因为面向过程的编程方式容易理解算法的原理,但是呢,如果很长时间没写算法,那么就意味着C语言的某些语法就生疏了,但是总有那么一些,在写算法的时候,特 ...

  10. HDU - 1160 (FatMouse&&num;39&semi;s Speed )最长上升子序列

    题意:一个元素有两个属性 w 和 sp 求在w严格递增的情况下 sp严格递减 用结构体 定义三个参数  w  sp  ix , ix是在输入时的顺序  因为我们要排序 之后把结构体数组 按从小到大排序 ...