Skip to content

Commit

Permalink
add background broad of the button icon
Browse files Browse the repository at this point in the history
  • Loading branch information
niu541412 committed May 30, 2024
1 parent f254777 commit 585f500
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
2. 增加新标签页打开的选项。
3. 修复快捷键问题。
4. 选项页修改了保存按钮。
5. 给按钮增加了一个外框,用以区分其他插件。

- ### 2.1.0
更新一波图标,默认增加抖音
Expand Down
38 changes: 32 additions & 6 deletions bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,12 +443,38 @@ var OneClick = Class(ObjectClass, {
setShortcut: function (s) {
localStorage.setItem(('shortcut'), s);
},
// move to an action proxy if necessary;
setIogo: function (tab, path) {
console.log("setting logo...");
var cvs = document.createElement('canvas');
var img = document.createElement('img');
img.onload = function () {
var ctx = cvs.getContext('2d');
ctx.globalAlpha = 0.7;
var upPath = new Path2D();
upPath.roundRect(0, 0, 32, 16, [7.5, 7.5, 0, 0]);
ctx.fillStyle = "#fff";
ctx.fill(upPath, "evenodd");

var downPath = new Path2D();
downPath.roundRect(0, 16, 32, 16, [0, 0, 7.5, 7.5]);
ctx.fillStyle = "#000";
ctx.fill(downPath, "evenodd");

ctx.globalAlpha = 1;
ctx.drawImage(img, 2, 2, 28, 28);
chrome.pageAction.setIcon({
imageData: ctx.getImageData(0, 0, 32, 32),
tabId: tab.id
});
};
img.src = path;
},
swichSupport: function (tab, site) {
chrome.pageAction.setIcon({
tabId: tab.id,
path: site.getIcon()
});
// chrome.pageAction.setIcon({
// tabId: tab.id,
// path: site.getIcon()
// });
this.setIogo(tab, site.getIcon());
chrome.pageAction.setTitle({
tabId: tab.id,
title: site.getTip()
Expand Down Expand Up @@ -534,4 +560,4 @@ var App = new OneClick();
function main() {
App.start();
}
main();
main();
Binary file modified icon/baidu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@
"*://*/*"
],
"short_name": "一键切换",
"version": "2.3.4"
"version": "2.3.5"
}

0 comments on commit 585f500

Please sign in to comment.