typora 无限试用|去除弹窗|修改未激活按钮|Typora实现cnblog文章的推送
改注册表无限试用
start.bat文件
@echo off
setlocal enabledelayedexpansion
chcp 65001 > nulREM 获取当前日期,格式为MM/dd/yyyy
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set datetime=%%a
set "year=!datetime:~0,4!"
set "month=!datetime:~4,2!"
set "day=!datetime:~6,2!"
set "date=!month!/!day!/!year!"REM 设置注册表项
reg add "HKEY_CURRENT_USER\Software\Typora" /v IDate /t REG_SZ /d "!date!" /f > nulendlocal
去除弹窗
D:\Typora\resources\page-dist\license.html
在文件最后的这里添加如下:
<script>setTimeout(function () {window.close();}, 30);
</script>
修改未激活按钮
D:\Typora\resources\locales\zh-Hans.lproj\Panel.json
找到UNREGISTERED把未激活改成别的
这个按钮看着别扭可以改成自己喜欢的文本
"UNREGISTERED": "快乐每一天,加油xxx",
Typora实现cnblog文章的推送
要使用博客园的 MetaWeblog API, 要在设置中进行简单的设置
cnblogsImage.py
import xmlrpc.client
import ssl
import os
import json
import sys
ssl._create_default_https_context = ssl._create_unverified_contextrootPath = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(rootPath,"cnblogs.json"),"rb") as f:config = json.loads(f.read())def uploadImage(images):for image in images:with open(image,"rb") as f:imageData = f.read()baseName = os.path.basename(image)suffix = baseName.split(".")[-1]file = dict(bits = imageData,name = baseName,type = f"image/{suffix}")proxy = xmlrpc.client.ServerProxy(config["url"])s = proxy.metaWeblog.newMediaObject('', config['username'], config['password'],file)print(s["url"])if __name__ == '__main__':uploadImage(sys.argv[1:])
cnblogsArticle.py
import xmlrpc.client
import ssl
import os
import json
import sys
ssl._create_default_https_context = ssl._create_unverified_contextrootPath = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(rootPath,"cnblogs.json"),"rb") as f:config = json.loads(f.read())def uploadArticle(articles):for article in articles:with open(article,"r",encoding="utf8") as f:data = f.read()title = os.path.basename(article)[:-3]post = dict(dateCreated = xmlrpc.client.DateTime(),description = data,title = title,categories = ['[Markdown]'],)proxy = xmlrpc.client.ServerProxy(config["url"])s = proxy.metaWeblog.newPost('', config['username'], config['password'],post,True)# 输出文章连接userName = config["url"].split("/")[-1]print(f"https://www.cnblogs.com/{userName}/p/{s}.html")if __name__ == '__main__':uploadArticle(sys.argv[1:])
cnblogs.json
如果要使用上传文章到博客圆,或者使用博客园图床,首先要对 cnblogs.json
进行修改:
{"url": "https://rpc.cnblogs.com/metaweblog/user","username": "user","password": "12345678"
}
注意:cnblogs.json和cnblogsImage.py、cnblogsArticle.py处于同一目录下
配置使用typora图床:
命令:
D:/Python36/python.exe D:/software/Typora/command/cnblogsImage.py
这里最好都使用绝对路径进行配置,否则可能会有找不到脚本的问题。
上传文章到博客园:
命令:
D:/Python36/python.exe D:/software/Typora/command/cnblogsArticle.py "${currentPath}"
${currentPath}
表示的是完整的markdown文件路径。
2022/8/23
目前博客园取消了密码的登录,因此需要在下边自己创建一个令牌,用令牌把密码替换即可