Skip to content

Commit

Permalink
0.5.3, add "Copy Markdown text"
Browse files Browse the repository at this point in the history
  • Loading branch information
Fradeet committed Oct 16, 2022
1 parent 5b2ceca commit 217876a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
6 changes: 4 additions & 2 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"message":"Empty list."
},
"uiLocaleText":{
"message":"{\"exportMD\":\"Export to MarkDown File\",\"Clipeet_popupMenuTitle\":\"Clipeet-PopUp\",\"clearPopupList\":\"Clear\",\"addWebPageToList\":\"AddTo\",\"currentListName\":\"CurrentList: \",\"editListName\":\"Rename\"}"
}
"message":"{\"exportMD\":\"Export to MarkDown File\",\"copyMD\":\"Copy Markdown text\",\"Clipeet_popupMenuTitle\":\"Clipeet-PopUp\",\"clearPopupList\":\"Clear\",\"addWebPageToList\":\"AddTo\",\"currentListName\":\"CurrentList: \",\"editListName\":\"Rename\"}"
},
"copyMDSuccess":{"message":"Copied."},
"exportMDSuccess":{"message":"Downloading..."}
}
6 changes: 4 additions & 2 deletions _locales/zh/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"message":"啊哦,还没有剪藏哦,试试在页面上选中文本点击右键菜单内的“记广”吧。"
},
"uiLocaleText":{
"message":"{\"exportMD\":\"导出为MD文件\",\"Clipeet_popupMenuTitle\":\"记广Clipeet-快捷菜单\",\"clearPopupList\":\"清空列表\",\"addWebPageToList\":\"添加页面\",\"currentListName\":\"当前目录名:\",\"editListName\":\"修改名字\"}"
}
"message":"{\"exportMD\":\"导出为MD文件\",\"copyMD\":\"复制MD文本\",\"Clipeet_popupMenuTitle\":\"记广Clipeet-快捷菜单\",\"clearPopupList\":\"清空列表\",\"addWebPageToList\":\"添加页面\",\"currentListName\":\"当前目录名:\",\"editListName\":\"修改名字\"}"
},
"copyMDSuccess":{"message":"已复制!"},
"exportMDSuccess":{"message":"下载中……"}
}
1 change: 1 addition & 0 deletions front.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<button type="button" class="btn btn-danger" id="click_clearFolder" title="Clear List" ></button>
<!-- <button type="button" class="btn btn-secondary" id="manage_button"></button> -->
<button type="button" class="btn btn-success" id="export-markdown"></button>
<button type="button" class="btn btn-success" id="copy-markdown"></button>
<!--id有时用于设定为处理函数-->
<!--<a href="./config.html" id="configLink" target="_blank">设置页面</a>
-->
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_titleName__",
"description": "跨多页面摘抄笔记",
"version": "0.5.2",
"version": "0.5.3",
"default_locale":"zh",
"manifest_version": 3,
"permissions": [
Expand Down
32 changes: 32 additions & 0 deletions popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var urlExport,titleExport,clipExport
//UI本地化字典 Dictionary-initialize locale language UI
var uiDict = JSON.parse(chrome.i18n.getMessage("uiLocaleText"));
document.getElementById("export-markdown").innerHTML = uiDict["exportMD"];
document.getElementById("copy-markdown").innerHTML = uiDict["copyMD"];
document.getElementById("popup_pagetitle").innerHTML = uiDict["Clipeet_popupMenuTitle"];
document.getElementById("click_clearFolder").innerHTML = uiDict["clearPopupList"];
document.getElementById("click_addWeb").innerHTML = "<img src=\"icons/bookmark-plus.svg\" alt=\"Bootstrap\" width=\"20\" height=\"20\" class=\"black-2-write\" id=\"pageStatus\">" + uiDict["addWebPageToList"];
Expand Down Expand Up @@ -349,10 +350,41 @@ function ExportFolder(){
}
fileName = name+ " " + Date() + ".md";
CreateAndDownloadFile(fileName,finalExportText);//这里后面加个时间
document.getElementById("export-markdown").innerHTML = chrome.i18n.getMessage("exportMDSuccess");
})
})
})
})
}
let btnExport = document.getElementById("export-markdown"); //获取id为xx的元素
btnExport.onclick = ExportFolder;

function CopyFolder(){
//打开3个数据表后一个一个来
chrome.storage.local.get({"webTitleList":[]},function(object){
titleExport = object["webTitleList"];
chrome.storage.local.get({"webClipList":[]},function(object){
clipExport = object["webClipList"];
chrome.storage.local.get({"websiteList":[]},function(object){
urlExport = object["websiteList"];
chrome.storage.local.get("folderName", function (object) { //获取所有剪藏
let name = object["folderName"];
//let num = urlExport.length;
//使用Windows的换行模式
let finalExportText = "# " + name + "\r\n";
for (let webNumber = 0; webNumber < urlExport.length; webNumber++) {
finalExportText = finalExportText + "[" +titleExport[webNumber] + "](" + urlExport[webNumber] + ")\r\n";
clipExport[webNumber].forEach(function (clipText) {
finalExportText = finalExportText + "- " + clipText + "\r\n";
})
finalExportText = finalExportText + "\r\n";
}
navigator.clipboard.writeText(finalExportText);//写入剪贴板 Write Clipboard
document.getElementById("copy-markdown").innerHTML = chrome.i18n.getMessage("copyMDSuccess");
})
})
})
})
}
let btnCopy = document.getElementById("copy-markdown"); //获取id为xx的元素
btnCopy.onclick = CopyFolder;

0 comments on commit 217876a

Please sign in to comment.