豆瓣备份

备粮、备荒

  1. // ==UserScript==
  2. // @icon https://img3.doubanio.com/favicon.ico
  3. // @name 豆瓣备份
  4. // @namespace https://www.douban.com/people/57965364/
  5. // @author 57965364
  6. // @description 备粮、备荒
  7. // @match https://*.douban.com/*
  8. // @version 0.0.1
  9. // @require https://gf.qytechs.cn/scripts/387261-douban-photo-lib/code/douban_photo_Lib.js?version=715521
  10. // @require https://unpkg.com/dexie@latest/dist/dexie.js
  11. // @require https://gf.qytechs.cn/scripts/387262-douban-note-lib/code/douban_note_Lib.js?version=715522
  12. // @require https://gf.qytechs.cn/scripts/387124-filesaver-lib/code/FileSaver_Lib.js?version=715484
  13. // @require https://gf.qytechs.cn/scripts/387126-html-docx-lib/code/html_docx_Lib.js?version=714522
  14. // @require https://gf.qytechs.cn/scripts/387267-douban-book-lib/code/douban_book_Lib.js?version=715562
  15. // @require https://gf.qytechs.cn/scripts/387268-douban-movie-lib/code/douban_movie_Lib.js?version=715564
  16. // @require https://gf.qytechs.cn/scripts/387271-douban-music-lib/code/douban_music_Lib.js?version=715570
  17. // @grant GM_addStyle
  18. // @grant GM_download
  19. // @grant GM_xmlhttpRequest
  20. // ==/UserScript==
  21. (function () {
  22. 'use strict';
  23.  
  24. var ul = document.getElementsByClassName('global-nav-items')[0].getElementsByTagName("ul")[0];
  25. var newli = document.createElement('li');
  26.  
  27. var mLink = document.createElement('a');
  28. mLink.setAttribute('target', '_blank');
  29. mLink.setAttribute('class', 'bn-more');
  30. mLink.setAttribute('rel', 'off');
  31. var mSpan1 = document.createElement('span');
  32. var text1 = document.createTextNode("备份");
  33. mSpan1.appendChild(text1);
  34. var mSpan2 = document.createElement('span');
  35. mSpan2.setAttribute('class', 'arrow');
  36. mLink.appendChild(mSpan1);
  37. mLink.appendChild(mSpan2);
  38. newli.appendChild(mLink);
  39.  
  40. var mDiv = document.createElement('div');
  41. mDiv.setAttribute("class", "more-items");
  42. var mtable = document.createElement('table');
  43. mtable.setAttribute("cellpadding", "0");
  44. mtable.setAttribute("cellspacing", "0");
  45. mtable.setAttribute("id", "backup_table");
  46. var mtbody = document.createElement("tbody");
  47. var mTitles = ['日记', '照片', '读书', '电影', '音乐'];
  48. for (var i = 0; i < mTitles.length; i++) {
  49. var R = document.createElement("tr");
  50. R.setAttribute("id", i);
  51. var C = document.createElement("td");
  52. var tempATag = document.createElement('a');
  53. tempATag.appendChild(document.createTextNode(mTitles[i]));
  54. tempATag.style.color = '#3d3d3d';
  55. C.appendChild(tempATag);
  56. R.appendChild(C);
  57. mtbody.appendChild(R);
  58. }
  59. mtable.appendChild(mtbody);
  60. mDiv.appendChild(mtable);
  61. newli.appendChild(mDiv);
  62.  
  63. ul.appendChild(newli);
  64.  
  65. addRowHandlers();
  66.  
  67. function addRowHandlers() {
  68. var table = document.getElementById("backup_table");
  69. var rows = table.getElementsByTagName("tr");
  70. for (i = 0; i < rows.length; i++) {
  71. var currentRow = table.rows[i];
  72. var createClickHandler = function (row) {
  73. return function () {
  74. var id = row.getAttribute("id");
  75. console.log(unsafeWindow._GLOBAL_NAV.USER_ID);
  76. if (unsafeWindow._GLOBAL_NAV.USER_ID != null) {
  77. if (id == 0) {
  78. if (window.location.host.startsWith("www.douban.com")) {
  79. downloadNotes(unsafeWindow._GLOBAL_NAV.USER_ID, saveAs, htmlDocx);
  80. } else {
  81. alert("去www.douban.com下载");
  82. }
  83. } else if (id == 1) {
  84. if (window.location.host.startsWith("www.douban.com")) {
  85. const db = new Dexie("豆瓣相册详情");
  86. db.version(1).stores({
  87. items: `++id, album, pid, date, desc`
  88. });
  89. downloadPhotos(unsafeWindow._GLOBAL_NAV.USER_ID, db);
  90. } else {
  91. alert("去www.douban.com下载");
  92. }
  93. } else if (id == 2) {
  94. if (window.location.host.startsWith("book.douban.com")) {
  95. const db_read_collection = new Dexie("豆瓣读书(已读)");
  96. db_read_collection.version(1).stores({
  97. items: `++id, title, pub, rating, date, tags, link, comment`
  98. });
  99. const db_read_wish = new Dexie("豆瓣读书(想读");
  100. db_read_wish.version(1).stores({
  101. items: `++id, title, pub, rating, date, tags, link, comment`
  102. });
  103. const db_read_do = new Dexie("豆瓣读书(在读)");
  104. db_read_do.version(1).stores({
  105. items: `++id, title, pub, rating, date, tags, link, comment`
  106. });
  107. downloadBooks(unsafeWindow._GLOBAL_NAV.USER_ID, db_read_collection,
  108. db_read_wish, db_read_do, saveAs, htmlDocx);
  109. } else {
  110. alert("去book.douban.com下载");
  111. }
  112. } else if (id == 3) {
  113. if (window.location.host.startsWith("movie.douban.com")) {
  114. const db_movie_collection = new Dexie("豆瓣电影(看过)");
  115. db_movie_collection.version(1).stores({
  116. items: `++id, title, intro, rating, date, tags, link, comment`
  117. });
  118. const db_movie_wish = new Dexie("豆瓣电影(想看)");
  119. db_movie_wish.version(1).stores({
  120. items: `++id, title, intro, rating, date, tags, link, comment`
  121. });
  122. const db_movie_do = new Dexie("豆瓣电影(在读)");
  123. db_movie_do.version(1).stores({
  124. items: `++id, title, intro, rating, date, tags, link, comment`
  125. });
  126. downloadMovie(unsafeWindow._GLOBAL_NAV.USER_ID, db_movie_collection,
  127. db_movie_wish, db_movie_do, saveAs, htmlDocx);
  128. } else {
  129. alert("movie.douban.com下载");
  130. }
  131. } else if (id == 4) {
  132. if (window.location.host.startsWith("music.douban.com")) {
  133. const db_music_collection = new Dexie("豆瓣音乐(已听)");
  134. db_music_collection.version(1).stores({
  135. items: `++id, title, intro, rating, date, tags, link,comment`
  136. });
  137. const db_music_wish = new Dexie("豆瓣音乐(想听)");
  138. db_music_wish.version(1).stores({
  139. items: `++id, title, intro, rating, date, tags, link, comment`
  140. });
  141. const db_music_do = new Dexie("豆瓣音乐(在听)");
  142. db_music_do.version(1).stores({
  143. items: `++id, title, intro, rating, date, tags, link, comment`
  144. });
  145. downloadMusic(unsafeWindow._GLOBAL_NAV.USER_ID, db_music_collection,
  146. db_music_wish, db_music_do, saveAs, htmlDocx);
  147. } else {
  148. alert("music.douban.com下载");
  149. }
  150. }
  151. } else {
  152. alert("麻烦先登陆一下");
  153. }
  154. };
  155. };
  156. currentRow.onclick = createClickHandler(currentRow);
  157. }
  158. }
  159.  
  160. })();

QingJ © 2025

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