Add files via upload

This commit is contained in:
林木木
2022-10-09 21:08:57 +08:00
committed by GitHub
parent 3b09ba3255
commit b09ebc960f
12 changed files with 585 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Charles Chin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+6 -2
View File
@@ -1,2 +1,6 @@
# memos-bber
Memos 的 Chrome 扩展
## 说明
一个通过浏览器插件发布 [memos](https://usememos.com/) 的插件。
基于 iSpeak-bber 修改,原作者为 [DreamyTZK](https://www.antmoe.com/)。
+18
View File
@@ -0,0 +1,18 @@
{
"actionTitle": {
"description": "按钮标题",
"message": "发送 Memos"
},
"extDescription": {
"description": "扩展描述",
"message": "一键发送灵感时刻,珍藏你的记忆"
},
"extName": {
"description": "扩展名称",
"message": "Memos-lmm"
},
"selectionMenu": {
"description": "菜单(选中)",
"message": "发送选中内容"
}
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

+211
View File
@@ -0,0 +1,211 @@
button, input, textarea {
font-family: inherit;
font-size: 100%;
font-weight: inherit;
line-height: inherit;
color: inherit;
margin: 0;
padding: 0;
border: none;
outline: none;
}
input:focus::-moz-placeholder ,.common-editor-inputer:focus::-moz-placeholder {
color: #d3d3d3
}
input:focus::placeholder ,.common-editor-inputer:focus::placeholder {
color: #d3d3d3
}
.body{
min-width:350px;
background-color: #f6f5f4;
padding:0 1rem 1rem;
font-family: eafont,PingFang SC,Hiragino Sans GB,Microsoft YaHei,STHeiti,WenQuanYi Micro Hei,Helvetica,Arial,sans-serif;
font-size: 16px;
font-size: 1rem;
line-height: 1.5;
position: relative;
}
.title{
font-size: 1.125rem;
font-weight: 700;
line-height: 2.5rem;
color: rgb(55,65,81);
}
.memo-editor{
border: 2px solid rgb(229,231,235);
border-radius: .5rem;
background-color: rgb(255,255,255);
margin-top:0.8rem;
padding: 0.8rem;
transition-property: all;
transition-timing-function: cubic-bezier(.4,0,.2,1);
transition-duration: .15s;
}
.btns-container{text-align:right;}
.common-editor-inputer,input.inputer{
font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;
margin-top: .25rem;
margin-bottom: .25rem;
height: 100%;
width: 100%;
resize: none;
overflow-y: auto;
overflow-x: hidden;
white-space: pre-wrap;
background-color: transparent;
font-size: 1rem;
min-height: 40px;
max-height: 300px;
scrollbar-width: none;
}
input.inputer{border-bottom: 1px solid #ccc;width:75%;}
#saveKey{margin:0;flex:1;}
.common-tools-wrapper {
position: relative;
display: flex;
width: 100%;
flex-direction: row;
align-items: center;
justify-content: space-between;
margin-top: 1rem;
}
.confirm-btn {
display: inline-flex;
cursor: pointer;
flex-direction: row;
align-items: center;
justify-content: center;
background-color: rgb(22,163,74);
padding:0 1rem;
font-size: .875rem;
line-height: 2rem;
color: rgb(255,255,255);
box-shadow: 0 1px 3px 0
rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
user-select: none;
border-radius: .25rem;
border-style: none;
opacity: .6;
}
.confirm-btn:hover {
opacity: 1;
}
.confirm-btn:disabled{
opacity: .6;
cursor: not-allowed;
}
svg.icon{width:24px;height:24px;}
#tags svg{opacity: 0.6;}
#tags:hover svg{opacity: 1;cursor: pointer;}
#taglist{display: none;}
.tag-list {
margin-top: .5rem;
max-height: 13rem;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
font-family: ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;
}
.tag-list>.item-container {
display: inline-block;
background-color: #666;
cursor: pointer;
padding: .2rem .5rem;
border-radius: .25rem;
font-size: .875rem;
line-height: 1.25rem;
color: #fff;
margin:0 6px 6px 0;
}
#blog_info_edit{
position: absolute;
right: 1rem;
top: 0.5rem;
}
#blog_info{
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
}
.tip{
margin-left: 36%;
max-width: 640px;
position: fixed;
text-align: center;
top: 15px;
width: 58%;
z-index: 10001;
left: 50%;
margin-left: -320px;
}
.tip-info{
background: -webkit-gradient(linear,left top,right top,from(#9c51ff),to(#816bff));
background: -webkit-linear-gradient(90deg,#9c51ff,#816bff);
background: linear-gradient(90deg,#9c51ff,#816bff);
-moz-box-shadow: 3px 3px 20px #d7ceff38;
-webkit-box-shadow: 3px 3px 20px #d7ceff38;
box-shadow: 3px 3px 20px #d7ceff38;
color: #fff;
font-size: 12px;
padding: 8px 40px;
display: inline-block;
border-radius: 3px;
margin: 0;
line-height: 1;
font-weight: 300;
}
@-webkit-keyframes bounceIn {
0% {
opacity: 0;
-webkit-transform: scale(.3);
}
50% {
opacity: 1;
-webkit-transform: scale(1);
}
70% {
-webkit-transform: scale(.95);
}
100% {
-webkit-transform: scale(1);
}
}
@keyframes bounceIn {
0% {
opacity: 0;
transform: scale(.3);
}
50% {
opacity: 1;
transform: scale(1);
}
70% {
transform: scale(.95);
}
100% {
transform: scale(1);
}
}
.bounceIn {
-webkit-animation-name: bounceIn;
animation-name: bounceIn;
}
.animate {
-webkit-animation-duration: .3s;
animation-duration: .3s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
+58
View File
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta
name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
/>
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>MEMOS</title>
<link rel="stylesheet" href="../css/main.css" />
</head>
<body class="body">
<div class="title">MEMOS</div>
<div id="blog_info_edit"><svg t="1665246316837" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2597" width="32" height="32"><path d="M913.94086 431.828053c-4.878101-25.783223-20.693298-42.455951-40.947598-42.455951l-3.511987 0c-54.731532 0-99.248422-44.515866-99.248422-99.262748 0-17.294898 8.299013-37.015032 8.619308-37.798884 10.097986-22.722514 2.349511-50.567699-18.078751-64.859193l-102.701057-57.183374-1.509377-0.738827c-20.545942-8.909927-48.667419-3.207042-63.987337 12.753465-11.086499 11.434423-49.306986 44.037982-78.471213 44.037982-29.543873 0-67.849294-33.257451-78.992075-44.908816-15.293311-16.077164-43.12417-22.112624-63.902402-13.218046l-106.35733 58.272171-1.596358 1.016143c-20.430308 14.234189-28.207435 42.078351-18.165732 64.713884 0.346901 0.827855 8.676613 20.387329 8.676613 37.914518 0 54.746882-44.51689 99.262748-99.247398 99.262748l-4.149507 0c-19.617803 0-35.434024 16.671705-40.309054 42.455951-0.363274 1.814322-8.590656 45.446052-8.590656 80.429821 0 34.938744 8.227382 78.555124 8.590656 80.355119 4.875031 25.799596 20.691251 42.48665 40.946574 42.48665l3.511987 0c54.730509 0 99.247398 44.51689 99.247398 99.247398 0 17.411555-8.328689 37.058011-8.647961 37.812187-10.069333 22.766516-2.349511 50.567699 18.021445 64.787562l100.756775 56.531528 1.538029 0.696872c20.836561 9.17087 49.01432 3.191692 64.250326-13.464663 14.07353-15.207353 52.207036-46.782489 80.20981-46.782489 30.354332 0 69.445652 35.347043 80.706113 47.76691 10.387581 11.376095 26.349111 18.22713 42.687218 18.22713 7.631818 0 14.857383-1.511423 21.474081-4.354168l104.4724-57.574277 1.538029-0.989537c20.428262-14.276145 28.206412-42.077328 18.138102-64.727187-0.348947-0.842181-8.677637-20.402679-8.677637-37.928844 0-54.730509 44.51689-99.247398 99.248422-99.247398l4.093225 0c19.644409 0 35.488259-16.687054 40.365336-42.48665 0.347924-1.799996 8.588609-45.416376 8.588609-80.355119C922.529469 477.274104 914.288784 433.642374 913.94086 431.828053M862.982258 512.257873c0 22.605857-4.498454 51.655474-6.559393 63.785745-82.09781 6.732331-145.738245 75.335802-145.738245 158.303422 0 23.419386 7.430226 45.851281 11.377118 56.169277l-89.12076 49.216935c-4.38282-4.584412-17.325597-17.644869-34.939767-30.762631-30.93557-22.925129-60.595077-34.635845-88.106664-34.635845-27.278273 0-56.703443 11.420097-87.493703 34.05563-17.528212 12.768815-30.296003 25.479301-34.765805 30.18037l-85.724407-47.997154c4.179183-10.839883 11.405771-32.982182 11.405771-56.226582 0-82.96762-63.640436-151.571091-145.70857-158.303422-2.089591-12.130272-6.588045-41.178865-6.588045-63.785745 0-22.650883 4.498454-51.713802 6.588045-63.844074 82.068134-6.718005 145.70857-75.335802 145.70857-158.303422 0-23.288402-7.429203-45.792952-11.376095-56.095599l91.325985-50.190099c3.975545 3.976568 17.005302 16.730033 34.82311 29.411867 30.355355 21.663392 59.260685 32.633235 86.016049 32.633235 26.494421 0 55.19509-10.766205 85.346807-32.009018 17.963117-12.623505 30.964222-25.203008 34.736129-28.757974l87.900979 48.825009c-3.975545 10.244318-11.405771 32.676214-11.405771 56.18258 0 82.96762 63.640436 151.585417 145.738245 158.303422C858.483804 460.5717 862.982258 489.7523 862.982258 512.257873" p-id="2598"></path><path d="M510.215866 365.633445c-80.530105 0-146.056494 65.527412-146.056494 146.057517 0 80.543408 65.527412 146.043191 146.056494 146.043191 80.530105 0 146.057517-65.499783 146.057517-146.043191C656.273383 431.160857 590.74597 365.633445 510.215866 365.633445M596.725148 511.690962c0 47.693232-38.799678 86.491887-86.509283 86.491887-47.708582 0-86.479607-38.798655-86.479607-86.491887 0-47.665603 38.771025-86.479607 86.479607-86.479607C557.925471 425.212378 596.725148 464.025359 596.725148 511.690962" p-id="2599"></path></svg></div>
<div id="blog_info" class="">
<input
id="apiUrl"
class="inputer"
name="apiUrl"
type="text"
value=""
maxlength="245"
placeholder="请填入 Memos Open API 链接"
required
/>
<span id="saveKey" class="action-btn confirm-btn">保存</span>
</div>
<div class="memo-editor">
<textarea
class="common-editor-inputer"
rows="2"
name="text"
id="content"
placeholder="现在的想法是..."
required=""
style="height:80px;"
></textarea>
</div>
<div class="common-tools-wrapper">
<div id="tags">
<svg t="1665297587288" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="692" width="32" height="32"><path d="M128 341.333333m42.666667 0l682.666666 0q42.666667 0 42.666667 42.666667l0 0q0 42.666667-42.666667 42.666667l-682.666666 0q-42.666667 0-42.666667-42.666667l0 0q0-42.666667 42.666667-42.666667Z" fill="#666666" p-id="693"></path><path d="M422.613333 85.333333H426.666667a38.613333 38.613333 0 0 1 38.4 42.453334L387.84 900.266667a42.666667 42.666667 0 0 1-42.453333 38.4H341.333333a38.613333 38.613333 0 0 1-38.4-42.453334L380.16 123.733333a42.666667 42.666667 0 0 1 42.453333-38.4zM678.613333 85.333333H682.666667a38.613333 38.613333 0 0 1 38.4 42.453334L643.84 900.266667a42.666667 42.666667 0 0 1-42.453333 38.4H597.333333a38.613333 38.613333 0 0 1-38.4-42.453334L636.16 123.733333a42.666667 42.666667 0 0 1 42.453333-38.4z" fill="#666666" p-id="694"></path><path d="M128 597.333333m42.666667 0l682.666666 0q42.666667 0 42.666667 42.666667l0 0q0 42.666667-42.666667 42.666667l-682.666666 0q-42.666667 0-42.666667-42.666667l0 0q0-42.666667 42.666667-42.666667Z" fill="#666666" p-id="695"></path></svg>
</div>
<div class="btns-container" type="submit" name="submit" id="submit">
<button id="content_submit_text" class="action-btn confirm-btn">记下<img class="icon-img" src="../assets/logo_24x24.png"></button>
</div>
</div>
<div class="tag-list" id="taglist"></div>
<script src="../js/jquery.min.js"></script>
<script src="../js/message.js"></script>
<script src="../js/oper.js"></script>
</body>
</html>
+18
View File
@@ -0,0 +1,18 @@
chrome.contextMenus.create({
title: "记下 “%s”",
contexts: ['selection'],
onclick: function(info, tab){
//设定打开页面的一些初始值
console.log(info);
chrome.storage.sync.set({open_action: "save_text",open_content:info.selectionText}, function() {
chrome.windows.create({
url: chrome.extension.getURL("html/popup.html"),
left: 50,
top: 50,
width: 550,
height: 300,
type: "popup"
});
});
}
});
+2
View File
File diff suppressed because one or more lines are too long
+65
View File
@@ -0,0 +1,65 @@
/**
* 消息提示组件
*
* 1.调用
* 字符串类型参数: $.message('成功');
* 对象型参数:$.message({});
*
* 2.参数详解
* message:' 操作成功', //提示信息
time:'2000', //显示时间(默认:2s)
type:'success', //显示类型,包括4种:success.error,info,warning
showClose:false, //显示关闭按钮(默认:否)
autoClose:true, //是否自动关闭(默认:是)
*
* type:success,error,info,warning
*/
$.extend({
message: function(options) {
var defaults={
message:' 操作成功',
time:'2000',
autoClose: true,
onClose:function(){}
};
if(typeof options === 'string'){
defaults.message=options;
}
if(typeof options === 'object'){
defaults=$.extend({},defaults,options);
}
//message模版
var template='<div class="tip animate bounceIn">\n' +
' <p class="tip-info">'+defaults.message+'</p>\n' +
'</div>';
var _this=this;
var $body=$('body');
var $message=$(template);
var timer;
//移除所有并插入该消息
$('.tip').remove();
$body.append($message);
//居中
$message.css({
'margin-left':'-'+$message.width()/2+'px'
});
//自动关闭
if (defaults.autoClose){
timer=setTimeout(function(){
closeFn();
},defaults.time);
}
//关闭
var closeFn = function(){
$message.addClass('hide');
$message.remove();
defaults.onClose(defaults);
clearTimeout(timer);
};
}
});
+154
View File
@@ -0,0 +1,154 @@
/**
* open_action: 打开这个页面执行的操作
* open_text:打开这页面需要复原的输入框的内容
*/
get_info(function (info) {
if (info.status) {
//已经有绑定信息了,折叠
$('#blog_info').hide()
}
$('#apiUrl').val(info.apiUrl)
$('#content').val(info.open_content)
//从localstorage 里面读取数据
setTimeout(get_info, 1)
})
//监听输入结束,保存未发送内容到本地
$('#content').blur(function () {
chrome.storage.sync.set(
{ open_action: 'save_text', open_content: $('#content').val() },
function () {}
)
})
$('#saveKey').click(function () {
// 保存数据
chrome.storage.sync.set(
{
apiUrl: $('#apiUrl').val()
},
function () {
$.message({
message: '保存信息成功'
})
$('#blog_info').hide()
}
)
})
$('#tags').click(function () {
//add("要出入的文本");
get_info(function (info) {
if (info.status) {
var tagUrl = info.apiUrl.replace(/api\/memo/,'api/tag')
var tagDom = ""
$.get(tagUrl,function(data,status){
var arrData = data.data
$.each(arrData, function(i,obj){
tagDom += '<span class="item-container">#'+obj+'</span>'
});
//console.log(tagDom)
$("#taglist").html(tagDom).slideToggle()
});
} else {
$.message({
message: '请先填写好 API 链接'
})
}
})
})
$(document).on("click",".item-container",function () {
var tagHtml = $(this).text()+" "
add(tagHtml);
})
function add(str) {
var tc = document.getElementById("content");
var tclen = tc.value.length;
tc.focus();
if(typeof document.selection != "undefined"){
document.selection.createRange().text = str;
}else{
tc.value =
tc.value.substr(0, tc.selectionStart) +
str +
tc.value.substring(tc.selectionStart, tclen);
}
}
$('#blog_info_edit').click(function () {
$('#blog_info').slideToggle()
})
function get_info(callback) {
chrome.storage.sync.get(
{
apiUrl: '',
open_action: '',
open_content: ''
},
function (items) {
var flag = false
var returnObject = {}
if (items.apiUrl === '' || items.repo === '') {
flag = false
} else {
flag = true
}
returnObject.status = flag
returnObject.apiUrl = items.apiUrl
returnObject.open_content = items.open_content
returnObject.open_action = items.open_action
if (callback) callback(returnObject)
}
)
}
//发送操作
$('#content_submit_text').click(function () {
sendText()
})
function sendText() {
get_info(function (info) {
if (info.status) {
//信息满足了
$.message({message: '发送中'})
$("#content_submit_text").attr('disabled','disabled');
let content = $('#content').val()
$.ajax({
url:info.apiUrl,
type:"POST",
data:JSON.stringify({'content': content}),
contentType:"application/json;",
dataType:"json",
success: function(result){
//发送成功
chrome.storage.sync.set(
{ open_action: '', open_content: '' },
function () {
$.message({
message: '发送成功!'
})
$("#content_submit_text").removeAttr('disabled');
$('#content').val('')
}
)
},
error:function(err){//清空open_action(打开时候进行的操作),同时清空open_content
chrome.storage.sync.set(
{ open_action: '', open_content: '' },
function () {
$.message({
message: '网络问题发送成功!'
})
}
)},
})
} else {
$.message({
message: '请先填写好 API 链接'
})
}
})
}
+32
View File
@@ -0,0 +1,32 @@
{
"background": {
"scripts": [ "js/background.js" ]
},
"browser_action": {
"default_icon": "assets/logo_24x24.png",
"default_popup": "html/popup.html",
"default_title": "__MSG_actionTitle__"
},
"default_locale": "zh_CN",
"description": "__MSG_extDescription__",
"homepage_url": "https://immmmm.com",
"icons": {
"128": "assets/logo.png",
"16": "assets/logo.png",
"48": "assets/logo.png"
},
"manifest_version": 2,
"name": "__MSG_extName__",
"permissions": [ "storage", "webRequest", "contextMenus", "http://*/*", "https://*/*" ],
// 新增命令
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+D",
"mac": "MacCtrl+Shift+D"
},
"description": "Opens popup.html"
}
},
"version": "2022.10.09"
}