Skip to content

Commit

Permalink
fix:copy img invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-houzi committed Dec 28, 2021
1 parent ccbee07 commit 7a1adce
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 8 additions & 2 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ chrome.contextMenus.onClicked.addListener((clickData, tab) => {
} else {
let title = ''
let url = ''
let isImg = false
if (clickData.mediaType === 'image') {
// alt text
title = typeof(result) == 'undefined' ? '' : result
url = clickData.srcUrl
isImg = true
} else if (typeof(clickData.linkUrl) !== 'undefined') {
title = typeof(clickData.selectionText) == 'undefined' ? '未选中文字' : clickData.selectionText
url = clickData.linkUrl
Expand All @@ -34,10 +36,14 @@ chrome.contextMenus.onClicked.addListener((clickData, tab) => {
let urlMode = parseInt(localStorage.getItem("urlMode"))
let md = ''

if (isImg) {
md += '!'
}

if (urlMode === 1) {
md = `[${title}](${formatUrl(url)})`
md += `[${title}](${formatUrl(url)})`
} else {
md = `[${title}](${url})`
md += `[${title}](${url})`
}

copy(md)
Expand Down
6 changes: 2 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 2,
"name": "url2md",
"version": "1.0.0",
"description": "方便markdwon写作的小工具,复制url转成markdown格式",
"version": "1.1.0",
"description": "Copy & Convert Url to Markdown format - 方便markdwon写作的小工具,复制url转成markdown格式",
"icons":
{
"16": "img/icon.png",
Expand Down Expand Up @@ -31,8 +31,6 @@
[
"contextMenus",
"tabs",
"webRequest",
"webRequestBlocking",
"storage",
"http://*/*",
"https://*/*"
Expand Down

0 comments on commit 7a1adce

Please sign in to comment.