Q-note【网站备忘录】

一个超超超好用的备忘录/记事本/笔记本~再也不用担心忘记什么啦!自动通过域名分类,适用于全部网站~超实用的生产力工具~

目前为 2021-05-27 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Q-note【网站备忘录】
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2.0
  5. // @description 一个超超超好用的备忘录/记事本/笔记本~再也不用担心忘记什么啦!自动通过域名分类,适用于全部网站~超实用的生产力工具~
  6. // @author Priate
  7. // @match *://*/*
  8. // @grant GM_setValue
  9. // @grant GM_getValue
  10. // @grant GM_addStyle
  11. // @grant GM_setClipboard
  12. // @require https://cdn.jsdelivr.net/npm/vue
  13. // @icon https://priate.oss-cn-beijing.aliyuncs.com/products/picture/icon/q-note.png
  14. // @require https://cdn.jsdelivr.net/npm/sweetalert@2.1.2/dist/sweetalert.min.js
  15. // @supportURL https://gf.qytechs.cn/zh-CN/scripts/421876/feedback
  16. // @source https://github.com/PriateXYF
  17. // @license MIT
  18. // ==/UserScript==
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. function initSetting(){
  24. if (!GM_getValue('priate_script_note_data')) {
  25. GM_setValue('priate_script_note_data', [])
  26. }
  27. if (!GM_getValue('priate_script_note_setting')) {
  28. GM_setValue('priate_script_note_setting', {
  29. hide : true,
  30. number : 0,
  31. left : 20,
  32. top : 100
  33. })
  34. }
  35. }
  36.  
  37. function injectDiv(){
  38. var priate_script_div = document.createElement("div")
  39. priate_script_div.innerHTML = `
  40. <div id="priate_script_div" :class="setting.hide || add ? '' : 'priate_script_hide'">
  41. <span v-show="!setting.hide" @click="showScript" class="hide-button">{{hideTipe}}</span>
  42. <div v-show="setting.hide">
  43. <b style='font-size:30px; margin: 0 0'>Q-note</b><p style='margin: 0 0'>by Priate</p>
  44. <button @click="showAdd">添加</button>
  45. <button @click='hideScript'>隐藏</button>
  46. <button id='readme' @click="clearHostData" v-show="filterData.length > 0">清空</button>
  47. <button @click='resetScript'>重置</button>
  48. </br>
  49. <table v-show="filterData.length > 0">
  50. <thead><tr><th>内容</th><th>时间</th><th>操作</th></tr></thead>
  51. <tbody id="priate_script_table">
  52. <tr v-for="(item, index) in filterData" key="index">
  53. <td v-show="!item.isHide"><a style='color:#337ab7' @click="copyNote(item.content)">{{item.content}}</a></td>
  54. <td v-show="item.isHide"><a style='color:blue' @click="showNote(item.id)">显示</a> | <a style='color:red' @click="copyNote(item.content)">复制</a></td>
  55. <td>{{item.time}}</td>
  56. <td><a style='color:#993333' @click="deleteNote(item.id)">删除</a> | <a style='color:green'>修改</a></td>
  57. </tr>
  58. </tbody>
  59. </table>
  60. </div>
  61. <div id="add_note" v-show="add">
  62. <h2>添加记录</h2>
  63. <table>
  64. <tr><td><textarea v-on:keydown.enter="submitAddNote" v-model="note.content" placeholder="添加笔记"></textarea></td></tr>
  65. <tr><td>隐藏文本<input v-model="note.isHide" type="checkbox"></td></tr>
  66. <tr><td><button @click="hideAdd">取消</button> <button @click="addNote">确定</button></td></tr>
  67. </table>
  68. </div>
  69. </div>
  70. `
  71. GM_addStyle(`
  72. #priate_script_div{
  73. font-size : 15px;
  74. position: fixed;
  75. background-color: rgba(240, 223, 175, 0.9);
  76. color : #660000;
  77. text-align : center;
  78. padding: 10px;
  79. z-index : 2147483647;
  80. border-radius : 20px;
  81. border:2px solid black;
  82. }
  83. #priate_script_div:hover{
  84. box-shadow: 5px 5px 5px #000000;
  85. transition: box-shadow 0.3s;
  86. }
  87. .priate_script_hide{
  88. padding: 0 !important;
  89. border:none !important;
  90. }
  91. a{
  92. cursor : pointer;
  93. text-decoration : none;
  94. }
  95. /*表格样式*/
  96. #priate_script_div table{
  97. text-align: center;
  98. border:2px solid #660000;
  99. margin: 5px auto;
  100. padding: 2px;
  101. border-collapse: collapse;
  102. }
  103. /*表格框样式*/
  104. #priate_script_div td{
  105. border:2px solid #660000;
  106. padding: 8px 12px;
  107. max-width : 300px;
  108. word-wrap : break-word;
  109. }
  110. /*表头样式*/
  111. #priate_script_div th{
  112. border:2px solid #660000;
  113. padding: 8px 12px;
  114. }
  115.  
  116. /*脚本按钮样式*/
  117. #priate_script_div button{
  118. display: inline-block;
  119. border-radius: 4px;
  120. border: 1px solid #660000;
  121. background-color: transparent;
  122. color: #660000;
  123. text-decoration: none;
  124. padding: 5px 10px;
  125. margin : 5px 10px;
  126. }
  127. /*脚本按钮悬浮样式*/
  128. #priate_script_div button:hover{
  129. cursor : pointer;
  130. color: rgb(240, 223, 175);
  131. background-color: #660000;
  132. }
  133. /*右下角显示按钮*/
  134. #priate_script_div .hide-button{
  135. z-index: 2147483647;
  136. width: 32px;
  137. height: 32px;
  138. cursor: pointer;
  139. position: fixed;
  140. left: 0px;
  141. bottom: 0px;
  142. color: #660000;
  143. text-align: center;
  144. line-height: 32px;
  145. margin: 10px;
  146. border-width: 1px;
  147. border-style: solid;
  148. border-color: #660000;
  149. border-image: initial;
  150. border-radius: 100%;
  151. }
  152. /*右下角显示按钮悬浮样式*/
  153. #priate_script_div .hide-button:hover{
  154. background-color : rgba(240, 223, 175, 0.9);
  155. }
  156. /*输入框样式*/
  157. #priate_script_div textarea{
  158. height : 50px;
  159. width : 200px;
  160. background-color: #fff;
  161. border:1px solid #000000;
  162. padding: 4px;
  163. }
  164. `);
  165. document.querySelector("html").appendChild(priate_script_div)
  166. var setting = GM_getValue('priate_script_note_setting')
  167. document.getElementById("priate_script_div").style.left = (setting.left || 20) + "px";
  168. document.getElementById("priate_script_div").style.top = (setting.top || 100) + "px";
  169. }
  170.  
  171. function dragFunc(id) {
  172. var Drag = document.getElementById(id);
  173. var setting = GM_getValue('priate_script_note_setting')
  174. Drag.onmousedown = function(event) {
  175. var ev = event || window.event;
  176. event.stopPropagation();
  177. var disX = ev.clientX - Drag.offsetLeft;
  178. var disY = ev.clientY - Drag.offsetTop;
  179. document.onmousemove = function(event) {
  180. var ev = event || window.event;
  181. setting.left = ev.clientX - disX
  182. Drag.style.left = setting.left + "px";
  183. setting.top = ev.clientY - disY
  184. Drag.style.top = setting.top + "px";
  185. Drag.style.cursor = "move";
  186. GM_setValue('priate_script_note_setting', setting)
  187. };
  188. };
  189. Drag.onmouseup = function() {
  190. document.onmousemove = null;
  191. this.style.cursor = "default";
  192. };
  193. };
  194.  
  195. // 获取当前时间
  196. function getNowFormatDate() {
  197. var date = new Date();
  198. var seperator1 = "-";
  199. var seperator2 = ":";
  200. var month = date.getMonth() + 1;
  201. var strDate = date.getDate();
  202. if (month >= 1 && month <= 9) {
  203. month = "0" + month;
  204. }
  205. if (strDate >= 0 && strDate <= 9) {
  206. strDate = "0" + strDate;
  207. }
  208. var currentdate = month + seperator1 + strDate + " " + date.getHours() + seperator2 + date.getMinutes()
  209. return currentdate;
  210. }
  211.  
  212. //初始化脚本设置
  213. initSetting()
  214. //注入脚本div
  215. injectDiv()
  216. // 处理数据等逻辑
  217. var vm = new Vue({
  218. el: '#priate_script_div',
  219. data: {
  220. setting: GM_getValue('priate_script_note_setting'),
  221. add: false,
  222. //添加的内容
  223. note : {
  224. content : "",
  225. // 是否隐藏
  226. isHide : false,
  227. },
  228. data: GM_getValue('priate_script_note_data'),
  229. },
  230. methods : {
  231. hideScript(){
  232. this.setting.hide = false
  233. GM_setValue('priate_script_note_setting', this.setting)
  234. swal("已隐藏!可以在左下角重新召唤出来哦~", {
  235. icon: "success",
  236. buttons: false,
  237. timer: 1500,
  238. });
  239. },
  240. showScript(){
  241. this.setting.hide = true
  242. this.add = false
  243. GM_setValue('priate_script_note_setting', this.setting)
  244. },
  245. showAdd(){
  246. this.add = true
  247. this.setting.hide = false
  248. },
  249. hideAdd(){
  250. this.add = false
  251. this.setting.hide = true
  252. },
  253. clearNote(){
  254. this.note = {
  255. content : "",
  256. // 是否隐藏
  257. isHide : false,
  258. }
  259. },
  260. addNote(){
  261. if(this.note.content.trim() == ""){
  262. swal("你还没有填写内容哦~", {
  263. icon: "warning",
  264. buttons: false,
  265. timer: 1500,
  266. });
  267. return
  268. }
  269. var origan_data = GM_getValue('priate_script_note_data')
  270. this.note.id = this.setting.number++
  271. this.note.time = getNowFormatDate()
  272. this.note.host = location.host
  273. origan_data.push(this.note)
  274. GM_setValue('priate_script_note_data', origan_data)
  275. this.data = origan_data
  276. this.hideAdd()
  277. GM_setValue('priate_script_note_setting', this.setting)
  278. this.clearNote()
  279. },
  280. // 重置脚本数据
  281. resetScript(){
  282. var _this = this
  283. swal({
  284. title: "是否重置全部脚本数据?",
  285. text: "重置后将清空全部数据并将设置变为默认!",
  286. icon: "warning",
  287. buttons: true
  288. }).then((willDelete) => {
  289. if (willDelete) {
  290. swal("重置成功!", {
  291. icon: "success",
  292. buttons: false,
  293. timer: 1000,
  294. });
  295. GM_setValue('priate_script_note_data', [])
  296. GM_setValue('priate_script_note_setting', {
  297. hide : true,
  298. number : 0,
  299. left : 20,
  300. top : 100
  301. })
  302. // 重新渲染样式和数据
  303. _this.data = []
  304. document.getElementById("priate_script_div").style.left = "20px";
  305. document.getElementById("priate_script_div").style.top = "100px";
  306. }
  307. })
  308. },
  309. deleteNote(id){
  310.  
  311. swal({
  312. title: "确定删除?",
  313. text: "删除后将无法恢复数据!",
  314. icon: "warning",
  315. buttons: true,
  316. }).then((willDelete) => {
  317. if (willDelete) {
  318. swal("删除成功!", {
  319. icon: "success",
  320. buttons: false,
  321. timer: 1000,
  322. });
  323. var origan_data = GM_getValue('priate_script_note_data');
  324. var new_data = origan_data.filter((item)=> item.id != id);
  325. GM_setValue('priate_script_note_data', new_data);
  326. this.data = new_data;
  327. }
  328. });
  329. },
  330. // 清空站点全部记录
  331. clearHostData(){
  332. swal({
  333. title: "是否清空数据??",
  334. text: "将会清空当前站点【" + location.host + "】下的全部数据!",
  335. icon: "warning",
  336. buttons: true
  337. }).then((willDelete) => {
  338. if (willDelete) {
  339. swal("清除成功!", {
  340. icon: "success",
  341. buttons: false,
  342. timer: 1000,
  343. });
  344. var origan_data = GM_getValue('priate_script_note_data')
  345. var new_data = origan_data.filter((item)=> item.host != location.host)
  346. GM_setValue('priate_script_note_data', new_data)
  347. this.data = new_data
  348. }
  349. })
  350. },
  351. // 显示隐藏的内容
  352. showNote(id){
  353. for(var index in this.data){
  354. if(this.data[index].id == id){
  355. this.data[index].isHide = false
  356. var item = this.data[index]
  357. // 恢复隐藏状态
  358. setTimeout(function(){
  359. item.isHide = true
  360. }, 1000)
  361. break
  362. }
  363. }
  364. },
  365. copyNote(content){
  366. console.log(content)
  367. GM_setClipboard(content)
  368. swal("复制成功!", {
  369. icon: "success",
  370. buttons: false,
  371. timer: 1000,
  372. });
  373. },
  374. //快捷键功能
  375. submitAddNote(e) {
  376. if (e.metaKey || e.altKey) {
  377. this.addNote()
  378. }
  379. },
  380. },
  381. computed: {
  382. filterData(){
  383. return this.data.filter((item)=> item.host == location.host)
  384. },
  385. hideTipe(){
  386. return this.filterData.length
  387. }
  388. }
  389. })
  390. //设置div可拖动
  391. dragFunc("priate_script_div");
  392. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址