Instagram - 为用户添加备注(别名/标签)

为用户添加备注(别名/标签)功能,以帮助识别和搜索

当前为 2021-08-13 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Instagram为关注用户添加备注
  3. // @name:en Instagram - Add notes(aliases/tags) to the user
  4. // @name:zh-CN Instagram - 为用户添加备注(别名/标签)
  5. // @name:zh-TW Instagram - 為用戶添加備註(別名/標籤)
  6. // @name:ja Instagram - ユーザーへのメモの追加(エイリアス/ラベル)
  7. // @name:ko Instagram - 사용자에게 메모 추가 (별칭/라벨)
  8. // @name:fr Instagram - ajouter des notes aux utilisateurs (alias/tag)
  9. // @namespace https://greasyfork.org/zh-CN/users/193133-pana
  10. // @homepage https://greasyfork.org/zh-CN/users/193133-pana
  11. // @icon data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiBhcmlhLWxhYmVsbGVkYnk9Im5ld0ljb25UaXRsZSIgc3Ryb2tlPSJyZ2JhKDI5LDE2MSwyNDIsMS4wMCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgZmlsbD0ibm9uZSIgY29sb3I9InJnYmEoMjksMTYxLDI0MiwxLjAwKSI+IDx0aXRsZSBpZD0ibmV3SWNvblRpdGxlIj5OZXc8L3RpdGxlPiA8cGF0aCBkPSJNMTkgMTRWMjJIMi45OTk5N1Y0SDEzIi8+IDxwYXRoIGQ9Ik0xNy40NjA4IDQuMDM5MjFDMTguMjQxOCAzLjI1ODE3IDE5LjUwODIgMy4yNTgxNiAyMC4yODkyIDQuMDM5MjFMMjAuOTYwOCA0LjcxMDc5QzIxLjc0MTggNS40OTE4NCAyMS43NDE4IDYuNzU4MTcgMjAuOTYwOCA3LjUzOTIxTDExLjU4NTggMTYuOTE0MkMxMS4yMTA3IDE3LjI4OTMgMTAuNzAyIDE3LjUgMTAuMTcxNiAxNy41TDcuNSAxNy41TDcuNSAxNC44Mjg0QzcuNSAxNC4yOTggNy43MTA3MSAxMy43ODkzIDguMDg1NzkgMTMuNDE0MkwxNy40NjA4IDQuMDM5MjFaIi8+IDxwYXRoIGQ9Ik0xNi4yNSA1LjI1TDE5Ljc1IDguNzUiLz4gPC9zdmc+
  12. // @version 5.3.3
  13. // @description 为用户添加备注(别名/标签)功能,以帮助识别和搜索
  14. // @description:en Add a note(alias/tag) for users to help identify and search
  15. // @description:zh-CN 为用户添加备注(别名/标签)功能,以帮助识别和搜索
  16. // @description:zh-TW 為用戶添加備註(別名/標籤)功能,以幫助識別和搜尋
  17. // @description:ja ユーザーが識別と検索に役立つメモ(エイリアス/タグ)機能を追加する
  18. // @description:ko 사용자 식별 및 검색에 도움이되는 메모 (별칭/태그) 기능 추가
  19. // @description:fr Ajouter une fonction de notes (alias/tag) pour les utilisateurs pour aider à identifier et rechercher
  20. // @license GNU General Public License v3.0 or later
  21. // @compatible chrome
  22. // @compatible firefox
  23. // @author pana
  24. // @include http*://*instagram.com/*
  25. // @require https://cdn.jsdelivr.net/npm/arrive@2.4.1/minified/arrive.min.js
  26. // @require https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js
  27. // @require https://cdn.jsdelivr.net/gh/LightAPIs/greasy-fork-library@d07ae4ecc5829d3674761f3069f8801b429bab49/Note_Obj.js
  28. // @grant GM_info
  29. // @grant GM.info
  30. // @grant GM_getValue
  31. // @grant GM.getValue
  32. // @grant GM_setValue
  33. // @grant GM.setValue
  34. // @grant GM_deleteValue
  35. // @grant GM.deleteValue
  36. // @grant GM_listValues
  37. // @grant GM.listValues
  38. // @grant GM_openInTab
  39. // @grant GM.openInTab
  40. // @grant GM_registerMenuCommand
  41. // @grant GM_unregisterMenuCommand
  42. // @grant GM_addValueChangeListener
  43. // @grant GM_removeValueChangeListener
  44. // ==/UserScript==
  45.  
  46. (async function () {
  47. 'use strict';
  48. if (typeof Note_Obj !== 'function') {
  49. alert('Note_Obj.js was not loaded successfully!');
  50. }
  51. const updated = '2021-08-13';
  52. const INS_ICON = {
  53. NOTE_BLACK:
  54. 'url(data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiBhcmlhLWxhYmVsbGVkYnk9Im5ld0ljb25UaXRsZSIgc3Ryb2tlPSJyZ2IoMzgsIDM4LCAzOCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgZmlsbD0ibm9uZSIgY29sb3I9InJnYigzOCwgMzgsIDM4KSI+IDx0aXRsZSBpZD0ibmV3SWNvblRpdGxlIj5OZXc8L3RpdGxlPiA8cGF0aCBkPSJNMTkgMTRWMjJIMi45OTk5N1Y0SDEzIi8+IDxwYXRoIGQ9Ik0xNy40NjA4IDQuMDM5MjFDMTguMjQxOCAzLjI1ODE3IDE5LjUwODIgMy4yNTgxNiAyMC4yODkyIDQuMDM5MjFMMjAuOTYwOCA0LjcxMDc5QzIxLjc0MTggNS40OTE4NCAyMS43NDE4IDYuNzU4MTcgMjAuOTYwOCA3LjUzOTIxTDExLjU4NTggMTYuOTE0MkMxMS4yMTA3IDE3LjI4OTMgMTAuNzAyIDE3LjUgMTAuMTcxNiAxNy41TDcuNSAxNy41TDcuNSAxNC44Mjg0QzcuNSAxNC4yOTggNy43MTA3MSAxMy43ODkzIDguMDg1NzkgMTMuNDE0MkwxNy40NjA4IDQuMDM5MjFaIi8+IDxwYXRoIGQ9Ik0xNi4yNSA1LjI1TDE5Ljc1IDguNzUiLz4gPC9zdmc+)',
  55. SERACH_BLUE:
  56. 'url(data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiBhcmlhLWxhYmVsbGVkYnk9InNlYXJjaEljb25UaXRsZSIgc3Ryb2tlPSJyZ2JhKDI5LDE2MSwyNDIsMS4wMCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgZmlsbD0ibm9uZSIgY29sb3I9InJnYmEoMjksMTYxLDI0MiwxLjAwKSI+IDx0aXRsZSBpZD0ic2VhcmNoSWNvblRpdGxlIj5TZWFyY2g8L3RpdGxlPiA8cGF0aCBkPSJNMTQuNDEyMTEyMiwxNC40MTIxMTIyIEwyMCwyMCIvPiA8Y2lyY2xlIGN4PSIxMCIgY3k9IjEwIiByPSI2Ii8+IDwvc3ZnPg==)',
  57. };
  58. const INS_STYLE = `
  59. .note-obj-ins-font-blue-color {
  60. color: #336699;
  61. }
  62. .note-obj-ins-background-box {
  63. display: inline-block;
  64. align-items: center;
  65. white-space: nowrap;
  66. border-radius: 50px;
  67. padding: 0px 10px;
  68. background-color: #336699;
  69. color: #fff;
  70. }
  71. .note-obj-ins-add-btn {
  72. background-image: ${INS_ICON.NOTE_BLACK};
  73. background-size: 24px;
  74. background-repeat: no-repeat;
  75. background-position: center;
  76. margin-left: 5px;
  77. cursor: pointer;
  78. width: 24px;
  79. height: 24px;
  80. }
  81. .note-obj-ins-homepage-btn {
  82. margin-top: 8px;
  83. }
  84. .note-obj-ins-userpage-btn {
  85. margin-top: 2px;
  86. }
  87. .note-obj-ins-userpage-tag {
  88. display: block;
  89. font-size: 20px;
  90. margin-bottom: 20px;
  91. white-space: nowrap;
  92. }
  93. .note-obj-ins-mobile-search-button {
  94. background-image: ${INS_ICON.SERACH_BLUE};
  95. background-size: 24px;
  96. background-repeat: no-repeat;
  97. background-position: center;
  98. cursor: pointer;
  99. min-width: 0px;
  100. height: 100%;
  101. flex: 1 1 auto;
  102. }
  103. .note-obj-ins-font-bold {
  104. font-weight: bold;
  105. }
  106. .note-obj-veryins-blue-tag {
  107. background-color: #3c81df;
  108. color: #fff;
  109. display: inline-flex;
  110. align-items: center;
  111. padding: 0px 10px;
  112. white-space: nowrap;
  113. line-height: 100%;
  114. border-radius: 50px;
  115. padding: 2px 10px;
  116. }
  117. .note-obj-veryins-userpage-btn {
  118. display: inline-block;
  119. vertical-align: middle;
  120. }
  121. `;
  122. var selector = {
  123. body: 'body',
  124. root: '#react-root',
  125. search: {
  126. frame: '.LWmhU',
  127. },
  128. homepage: {
  129. article: 'article',
  130. id: '.e1e1d a',
  131. id_shell: '.e1e1d',
  132. icon: 'span.wmtNn',
  133. comment_id: '.FPmhX',
  134. comment_at: '._8Pl3R .notranslate',
  135. },
  136. homepage_stories: {
  137. id: '.eebAO',
  138. id_shell: '.Fd_fQ',
  139. },
  140. homepage_recommend: {
  141. id: '.fDxYl a',
  142. },
  143. user_page: {
  144. frame: '.zwlfE',
  145. id: '.KV-D4',
  146. bar: '.AFWDX',
  147. box: '.nZSzR',
  148. common: 'span._32eiM',
  149. suggest: '.Qj3-a',
  150. info_at: '.notranslate',
  151. user_name: '.-vDIg .rhpdm',
  152. },
  153. stories: {
  154. id: '.FPmhX',
  155. id_shell: '.yn6BW',
  156. },
  157. watch_list: {
  158. initial_item: '.isgrP li',
  159. later_item: '.d7ByH',
  160. id: 'a.FPmhX',
  161. },
  162. dialog: {
  163. frame: '._2dDPU article',
  164. comment_id: '.EtaWk .ZIAjV',
  165. comment_at: '.EtaWk .notranslate',
  166. },
  167. request: {
  168. follow: '.yrJyr',
  169. },
  170. mobile: {
  171. bottom_bar: '.BvyAW',
  172. },
  173. suggest: {
  174. user: '.FPmhX.notranslate.MBL3Z',
  175. },
  176. };
  177. function instagram_Change_Event(note_obj, user_id = null) {
  178. for (let article of document.querySelectorAll(selector.homepage.article)) {
  179. let article_user = article.querySelector(selector.homepage.id);
  180. if (article_user) {
  181. let article_user_id = Note_Obj.fn.getUserIdFromLink(article_user.href);
  182. (!user_id || user_id == article_user_id) &&
  183. note_obj.handler(article_user_id, article_user, null, {
  184. add: note_obj.getConfig().other.replaceHomepageID ? null : 'span',
  185. classname: note_obj.getConfig().other.replaceHomepageID ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  186. title: note_obj.getConfig().other.replaceHomepageID,
  187. });
  188. }
  189. for (let comment of article.querySelectorAll(selector.homepage.comment_id)) {
  190. let comment_id = Note_Obj.fn.getUserIdFromLink(comment.href);
  191. (!user_id || user_id == comment_id) &&
  192. note_obj.handler(comment_id, comment, null, {
  193. classname: 'note-obj-ins-font-blue-color',
  194. });
  195. }
  196. for (let comment_at of article.querySelectorAll(selector.homepage.comment_at)) {
  197. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  198. (!user_id || user_id == comment_at_id) &&
  199. note_obj.handler(comment_at_id, comment_at, null, {
  200. symbol: {
  201. prefix: '@',
  202. },
  203. title: true,
  204. classname: 'note-obj-ins-font-blue-color',
  205. });
  206. }
  207. for (let pic_comment_user of article.querySelectorAll(selector.dialog.comment_id)) {
  208. let pic_comment_id = Note_Obj.fn.getUserIdFromLink(pic_comment_user.href);
  209. (!user_id || user_id == pic_comment_id) &&
  210. note_obj.handler(pic_comment_id, pic_comment_user, null, {
  211. title: true,
  212. classname: 'note-obj-ins-font-blue-color',
  213. });
  214. }
  215. for (let pic_comment_at of article.querySelectorAll(selector.dialog.comment_at)) {
  216. if (!pic_comment_at.classList.contains(selector.homepage.comment_id.replace(/^\.|\s+.*$/g, ''))) {
  217. let pic_comment_at_id = Note_Obj.fn.getUserIdFromLink(pic_comment_at.href);
  218. (!user_id || user_id == pic_comment_at_id) &&
  219. note_obj.handler(pic_comment_at_id, pic_comment_at, null, {
  220. symbol: {
  221. prefix: '@',
  222. },
  223. title: true,
  224. classname: 'note-obj-ins-font-blue-color',
  225. });
  226. }
  227. }
  228. }
  229. for (let homepage_stories of document.querySelectorAll(selector.homepage_stories.id_shell)) {
  230. if (homepage_stories.querySelector(selector.homepage_stories.id)) {
  231. let homepage_stories_id = homepage_stories.querySelector(selector.homepage_stories.id).textContent;
  232. if (!user_id || user_id == homepage_stories_id) {
  233. homepage_stories.title = note_obj.getUserTag(homepage_stories_id);
  234. }
  235. }
  236. }
  237. for (let homepage_recommend of document.querySelectorAll(selector.homepage_recommend.id)) {
  238. let homepage_recommend_id = Note_Obj.fn.getUserIdFromLink(homepage_recommend.href);
  239. (!user_id || user_id == homepage_recommend_id) &&
  240. note_obj.handler(homepage_recommend_id, homepage_recommend, null, {
  241. classname: 'note-obj-ins-font-blue-color',
  242. });
  243. }
  244. for (let user_page of document.querySelectorAll(selector.user_page.frame)) {
  245. if (user_page.querySelector(selector.user_page.id)) {
  246. let user_page_id = user_page.querySelector(selector.user_page.id).textContent;
  247. if (!user_id || user_id == user_page_id) {
  248. let user_page_tag = user_page.querySelector('.note-obj-user-tag');
  249. user_page_tag && user_page_tag.remove();
  250. note_obj.judgeUsers(user_page_id) &&
  251. user_page.querySelector(selector.user_page.box).after(
  252. note_obj.createNoteTag(
  253. user_page_id,
  254. {
  255. secondaryColor: false,
  256. offsetWidth: -20,
  257. },
  258. 'div',
  259. ['note-obj-ins-userpage-tag', 'note-obj-ins-font-blue-color', 'note-obj-ins-font-bold']
  260. )
  261. );
  262. }
  263. }
  264. for (let common_user of user_page.querySelectorAll(selector.user_page.common)) {
  265. let common_user_id = common_user.textContent;
  266. if (!user_id || user_id == common_user_id) {
  267. if (note_obj.judgeUsers(common_user_id)) {
  268. common_user.title = note_obj.getUserTag(common_user_id);
  269. if (note_obj.getShowNoteColorConfig()) {
  270. common_user.style.setProperty('color', note_obj.getPrimaryColor(common_user_id), 'important');
  271. } else {
  272. common_user.style.setProperty('color', '');
  273. }
  274. common_user.classList.add('note-obj-ins-font-blue-color');
  275. } else {
  276. (common_user.title = ''), common_user.style.setProperty('color', '');
  277. common_user.classList.remove('note-obj-ins-font-blue-color');
  278. }
  279. }
  280. }
  281. for (let info_at_user of user_page.querySelectorAll(selector.user_page.info_at)) {
  282. let info_at_user_id = Note_Obj.fn.getUserIdFromLink(info_at_user.href);
  283. (!user_id || user_id == info_at_user_id) &&
  284. note_obj.handler(info_at_user_id, info_at_user, null, {
  285. symbol: {
  286. prefix: '@',
  287. },
  288. classname: 'note-obj-ins-font-blue-color',
  289. title: true,
  290. });
  291. }
  292. }
  293. for (let stories_shell of document.querySelectorAll(selector.stories.id_shell)) {
  294. let stories = stories_shell.querySelector(selector.stories.id);
  295. if (stories) {
  296. let stories_user_id = Note_Obj.fn.getUserIdFromLink(stories.href);
  297. (!user_id || user_id == stories_user_id) &&
  298. note_obj.handler(stories_user_id, stories, null, {
  299. classname: 'note-obj-ins-font-blue-color',
  300. });
  301. }
  302. }
  303. for (let initial of document.querySelectorAll(selector.watch_list.initial_item)) {
  304. let initial_item = initial.querySelector(selector.watch_list.id);
  305. if (initial_item) {
  306. let initial_item_id = Note_Obj.fn.getUserIdFromLink(initial_item.href);
  307. (!user_id || user_id == initial_item_id) &&
  308. note_obj.handler(initial_item_id, initial_item, null, {
  309. classname: 'note-obj-ins-font-blue-color',
  310. });
  311. }
  312. }
  313. for (let later of document.querySelectorAll(selector.watch_list.later_item)) {
  314. let later_item = later.querySelector(selector.watch_list.id);
  315. if (later_item) {
  316. let later_item_id = Note_Obj.fn.getUserIdFromLink(later_item.href);
  317. (!user_id || user_id == later_item_id) &&
  318. note_obj.handler(later_item_id, later_item, null, {
  319. classname: 'note-obj-ins-font-blue-color',
  320. });
  321. }
  322. }
  323. for (let dialog of document.querySelectorAll(selector.dialog.frame)) {
  324. let dialog_a = dialog.querySelector(selector.homepage.id);
  325. if (dialog_a) {
  326. let dialog_a_id = Note_Obj.fn.getUserIdFromLink(dialog_a.href);
  327. (!user_id || user_id == dialog_a_id) &&
  328. note_obj.handler(dialog_a_id, dialog_a, null, {
  329. title: true,
  330. classname: 'note-obj-ins-font-blue-color',
  331. });
  332. }
  333. for (let like of dialog.querySelectorAll(selector.homepage.comment_id)) {
  334. let like_id = Note_Obj.fn.getUserIdFromLink(like.href);
  335. (!user_id || user_id == like_id) &&
  336. note_obj.judgeUsers(like_id) &&
  337. note_obj.handler(like_id, like, null, {
  338. classname: 'note-obj-ins-font-blue-color',
  339. });
  340. }
  341. for (let comment_user of dialog.querySelectorAll(selector.dialog.comment_id)) {
  342. let comment_id = Note_Obj.fn.getUserIdFromLink(comment_user.href);
  343. (!user_id || user_id == comment_id) &&
  344. note_obj.handler(comment_id, comment_user, null, {
  345. classname: 'note-obj-ins-font-blue-color',
  346. title: true,
  347. });
  348. }
  349. for (let comment_at of dialog.querySelectorAll(selector.dialog.comment_at)) {
  350. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  351. (!user_id || user_id == comment_at_id) &&
  352. note_obj.handler(comment_at_id, comment_at, null, {
  353. symbol: {
  354. prefix: '@',
  355. },
  356. classname: 'note-obj-ins-font-blue-color',
  357. title: true,
  358. });
  359. }
  360. }
  361. for (let follow of document.querySelectorAll(selector.request.follow)) {
  362. let follow_user_id = Note_Obj.fn.getUserIdFromLink(follow.href);
  363. (!user_id || user_id == follow_user_id) &&
  364. note_obj.handler(follow_user_id, follow, null, {
  365. classname: 'note-obj-ins-font-blue-color',
  366. });
  367. }
  368. for (let suggest_user of document.querySelectorAll(selector.suggest.user)) {
  369. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest_user.href);
  370. (!user_id || user_id == suggest_user_id) &&
  371. note_obj.handler(suggest_user_id, suggest_user, null, {
  372. classname: 'note-obj-ins-font-blue-color',
  373. });
  374. }
  375. for (let suggest of document.querySelectorAll(selector.user_page.suggest)) {
  376. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest.href);
  377. (!user_id || user_id == suggest_user_id) &&
  378. note_obj.handler(suggest_user_id, suggest, null, {
  379. classname: 'note-obj-ins-font-blue-color',
  380. });
  381. }
  382. }
  383. function instagram_Homepage_Event(newValue, oldValue) {
  384. if (newValue != oldValue) {
  385. for (let article of document.querySelectorAll(selector.homepage.article)) {
  386. let article_user = article.querySelector(selector.homepage.id);
  387. if (article_user) {
  388. let article_user_id = Note_Obj.fn.getUserIdFromLink(article_user.href);
  389. note_obj.handler(article_user_id, article_user, null, {
  390. add: oldValue ? null : 'span',
  391. classname: oldValue ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  392. title: oldValue,
  393. restore: true,
  394. });
  395. note_obj.handler(article_user_id, article_user, null, {
  396. add: newValue ? null : 'span',
  397. classname: newValue ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  398. title: newValue,
  399. });
  400. }
  401. }
  402. }
  403. }
  404. function init_Instagram(note_obj) {
  405. let arrive_option = {
  406. fireOnAttributesModification: true,
  407. existing: true,
  408. };
  409. Note_Obj.fn.isMobilePage() &&
  410. document
  411. .querySelector(selector.root)
  412. .arrive(selector.mobile.bottom_bar, arrive_option, item =>
  413. item.appendChild(note_obj.createSearchButton('note-obj-ins-mobile-search-button'))
  414. );
  415. document.querySelector(selector.root).arrive(selector.homepage.article, arrive_option, article => {
  416. let article_user = article.querySelector(selector.homepage.id);
  417. if (article_user) {
  418. let article_user_id = Note_Obj.fn.getUserIdFromLink(article_user.href);
  419. note_obj.judgeUsers(article_user_id) &&
  420. note_obj.handler(article_user_id, article_user, null, {
  421. add: note_obj.getConfig().other.replaceHomepageID ? null : 'span',
  422. classname: note_obj.getConfig().other.replaceHomepageID ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  423. title: note_obj.getConfig().other.replaceHomepageID,
  424. });
  425. article.querySelector(selector.homepage.icon) &&
  426. article
  427. .querySelector(selector.homepage.icon)
  428. .insertAdjacentElement(
  429. 'beforebegin',
  430. note_obj.createNoteBtn(article_user_id, null, ['note-obj-ins-add-btn', 'note-obj-ins-homepage-btn'])
  431. );
  432. }
  433. for (let comment of article.querySelectorAll(selector.homepage.comment_id)) {
  434. let comment_id = Note_Obj.fn.getUserIdFromLink(comment.href);
  435. note_obj.judgeUsers(comment_id) &&
  436. note_obj.handler(comment_id, comment, null, {
  437. classname: 'note-obj-ins-font-blue-color',
  438. });
  439. }
  440. article.arrive(selector.homepage.comment_at, arrive_option, comment_at => {
  441. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  442. note_obj.judgeUsers(comment_at_id) &&
  443. note_obj.handler(comment_at_id, comment_at, null, {
  444. symbol: {
  445. prefix: '@',
  446. },
  447. title: true,
  448. classname: 'note-obj-ins-font-blue-color',
  449. });
  450. });
  451. article.arrive(selector.dialog.comment_id, arrive_option, pic_comment_user => {
  452. let pic_comment_id = Note_Obj.fn.getUserIdFromLink(pic_comment_user.href);
  453. note_obj.judgeUsers(pic_comment_id) &&
  454. note_obj.handler(pic_comment_id, pic_comment_user, null, {
  455. title: true,
  456. classname: 'note-obj-ins-font-blue-color',
  457. });
  458. });
  459. article.arrive(selector.dialog.comment_at, arrive_option, pic_comment_at => {
  460. if (!pic_comment_at.classList.contains(selector.homepage.comment_id.replace(/^\.|\s+.*$/g, ''))) {
  461. let pic_comment_at_id = Note_Obj.fn.getUserIdFromLink(pic_comment_at.href);
  462. note_obj.judgeUsers(pic_comment_at_id) &&
  463. note_obj.handler(pic_comment_at_id, pic_comment_at, null, {
  464. symbol: {
  465. prefix: '@',
  466. },
  467. title: true,
  468. classname: 'note-obj-ins-font-blue-color',
  469. });
  470. }
  471. });
  472. });
  473. document.querySelector(selector.root).arrive(selector.homepage_stories.id_shell, arrive_option, homepage_stories => {
  474. if (homepage_stories.querySelector(selector.homepage_stories.id)) {
  475. let homepage_stories_id = homepage_stories.querySelector(selector.homepage_stories.id).textContent;
  476. if (note_obj.judgeUsers(homepage_stories_id)) {
  477. homepage_stories.title = note_obj.getUserTag(homepage_stories_id);
  478. }
  479. }
  480. });
  481. document.querySelector(selector.root).arrive(selector.homepage_recommend.id, arrive_option, homepage_recommend => {
  482. let homepage_recommend_id = Note_Obj.fn.getUserIdFromLink(homepage_recommend.href);
  483. note_obj.judgeUsers(homepage_recommend_id) &&
  484. note_obj.handler(homepage_recommend_id, homepage_recommend, null, {
  485. classname: 'note-obj-ins-font-blue-color',
  486. });
  487. });
  488. document.querySelector(selector.root).arrive(selector.user_page.frame, arrive_option, user_page => {
  489. if (user_page.querySelector(selector.user_page.id)) {
  490. let user_page_id = user_page.querySelector(selector.user_page.id).textContent;
  491. let user_name = user_page.querySelector(selector.user_page.user_name);
  492. let user_name_text = '';
  493. if (user_name) {
  494. user_name_text = user_page.querySelector(selector.user_page.user_name).textContent;
  495. }
  496. user_page.querySelector(selector.user_page.bar) &&
  497. user_page
  498. .querySelector(selector.user_page.bar)
  499. .after(note_obj.createNoteBtn(user_page_id, user_name_text, ['note-obj-ins-add-btn', 'note-obj-ins-userpage-btn']));
  500. note_obj.judgeUsers(user_page_id) &&
  501. user_page.querySelector(selector.user_page.box).after(
  502. note_obj.createNoteTag(
  503. user_page_id,
  504. {
  505. secondaryColor: false,
  506. offsetWidth: -20,
  507. },
  508. 'div',
  509. ['note-obj-ins-userpage-tag', 'note-obj-ins-font-blue-color', 'note-obj-ins-font-bold'],
  510. user_name_text
  511. )
  512. );
  513. }
  514. for (let common_user of user_page.querySelectorAll(selector.user_page.common)) {
  515. let common_user_id = common_user.textContent;
  516. if (note_obj.judgeUsers(common_user_id)) {
  517. common_user.title = note_obj.getUserTag(common_user_id);
  518. note_obj.getShowNoteColorConfig() &&
  519. common_user.style.setProperty('color', note_obj.getPrimaryColor(common_user_id), 'important');
  520. common_user.classList.add('note-obj-ins-font-blue-color');
  521. }
  522. }
  523. for (let info_at_user of user_page.querySelectorAll(selector.user_page.info_at)) {
  524. let info_at_user_id = Note_Obj.fn.getUserIdFromLink(info_at_user.href);
  525. note_obj.judgeUsers(info_at_user_id) &&
  526. note_obj.handler(info_at_user_id, info_at_user, null, {
  527. symbol: {
  528. prefix: '@',
  529. },
  530. classname: 'note-obj-ins-font-blue-color',
  531. title: true,
  532. });
  533. }
  534. });
  535. document.querySelector(selector.root).arrive(selector.stories.id_shell, arrive_option, stories_shell => {
  536. let stories = stories_shell.querySelector(selector.stories.id);
  537. if (stories) {
  538. let stories_user_id = Note_Obj.fn.getUserIdFromLink(stories.href);
  539. note_obj.judgeUsers(stories_user_id) &&
  540. note_obj.handler(stories_user_id, stories, null, {
  541. classname: 'note-obj-ins-font-blue-color',
  542. });
  543. }
  544. });
  545. document.querySelector(selector.body).arrive(selector.watch_list.initial_item, arrive_option, initial => {
  546. let initial_item = initial.querySelector(selector.watch_list.id);
  547. if (initial_item) {
  548. let initial_item_id = Note_Obj.fn.getUserIdFromLink(initial_item.href);
  549. note_obj.judgeUsers(initial_item_id) &&
  550. note_obj.handler(initial_item_id, initial_item, null, {
  551. classname: 'note-obj-ins-font-blue-color',
  552. });
  553. }
  554. });
  555. document.querySelector(selector.body).arrive(selector.watch_list.later_item, arrive_option, later => {
  556. let later_item = later.querySelector(selector.watch_list.id);
  557. if (later_item) {
  558. let later_item_id = Note_Obj.fn.getUserIdFromLink(later_item.href);
  559. note_obj.judgeUsers(later_item_id) &&
  560. note_obj.handler(later_item_id, later_item, null, {
  561. classname: 'note-obj-ins-font-blue-color',
  562. });
  563. }
  564. });
  565. document.querySelector(selector.body).arrive(selector.dialog.frame, arrive_option, dialog => {
  566. let dialog_a = dialog.querySelector(selector.homepage.id);
  567. if (dialog_a) {
  568. let dialog_a_id = Note_Obj.fn.getUserIdFromLink(dialog_a.href);
  569. note_obj.judgeUsers(dialog_a_id) &&
  570. note_obj.handler(dialog_a_id, dialog_a, null, {
  571. title: true,
  572. classname: 'note-obj-ins-font-blue-color',
  573. });
  574. dialog.querySelector(selector.homepage.icon) &&
  575. dialog
  576. .querySelector(selector.homepage.icon)
  577. .insertAdjacentElement(
  578. 'beforebegin',
  579. note_obj.createNoteBtn(dialog_a_id, null, ['note-obj-ins-add-btn', 'note-obj-ins-homepage-btn'])
  580. );
  581. }
  582. for (let like of dialog.querySelectorAll(selector.homepage.comment_id)) {
  583. let like_id = Note_Obj.fn.getUserIdFromLink(like.href);
  584. note_obj.judgeUsers(like_id) &&
  585. note_obj.handler(like_id, like, null, {
  586. classname: 'note-obj-ins-font-blue-color',
  587. });
  588. }
  589. dialog.arrive(selector.dialog.comment_id, arrive_option, comment_user => {
  590. let comment_id = Note_Obj.fn.getUserIdFromLink(comment_user.href);
  591. note_obj.judgeUsers(comment_id) &&
  592. note_obj.handler(comment_id, comment_user, null, {
  593. classname: 'note-obj-ins-font-blue-color',
  594. title: true,
  595. });
  596. });
  597. dialog.arrive(selector.dialog.comment_at, arrive_option, comment_at => {
  598. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  599. note_obj.judgeUsers(comment_at_id) &&
  600. note_obj.handler(comment_at_id, comment_at, null, {
  601. symbol: {
  602. prefix: '@',
  603. },
  604. classname: 'note-obj-ins-font-blue-color',
  605. title: true,
  606. });
  607. });
  608. });
  609. document.querySelector(selector.root).arrive(selector.request.follow, arrive_option, follow => {
  610. let follow_user_id = Note_Obj.fn.getUserIdFromLink(follow.href);
  611. note_obj.judgeUsers(follow_user_id) &&
  612. note_obj.handler(follow_user_id, follow, null, {
  613. classname: 'note-obj-ins-font-blue-color',
  614. });
  615. });
  616. document.querySelector(selector.root).arrive(selector.suggest.user, arrive_option, suggest_user => {
  617. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest_user.href);
  618. note_obj.judgeUsers(suggest_user_id) &&
  619. note_obj.handler(suggest_user_id, suggest_user, null, {
  620. classname: 'note-obj-ins-font-blue-color',
  621. });
  622. });
  623. document.querySelector(selector.root).arrive(selector.user_page.suggest, arrive_option, suggest => {
  624. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest.href);
  625. note_obj.judgeUsers(suggest_user_id) &&
  626. note_obj.handler(suggest_user_id, suggest, null, {
  627. classname: 'note-obj-ins-font-blue-color',
  628. });
  629. });
  630. }
  631. let note_obj = new Note_Obj('myInstagramNote');
  632. await note_obj.init({
  633. style: INS_STYLE,
  634. changeEvent: instagram_Change_Event,
  635. script: {
  636. author: {
  637. name: 'pana',
  638. homepage: 'https://greasyfork.org/zh-CN/users/193133-pana',
  639. },
  640. address: 'https://greasyfork.org/scripts/387871',
  641. updated: updated,
  642. library: [
  643. {
  644. name: 'arrive.js',
  645. version: '2.4.1',
  646. url: 'https://github.com/uzairfarooq/arrive',
  647. },
  648. ],
  649. },
  650. primaryColor: '#336699',
  651. settings: {
  652. replaceHomepageID: {
  653. type: 'checkbox',
  654. lang: {
  655. en: 'Allow to replace the user ID on the instagram homepage',
  656. zh_cn: '允许替换 Instagram 首页上的用户 ID',
  657. zh_tw: '允許替換 Instagram 首頁上的用戶 ID',
  658. ja: 'Instagram ホームページのユーザーIDの置き換えを許可する',
  659. ko: 'Instagram 첫 페이지에 있는 사용자 ID 바꾸기 허용',
  660. fr: "Permettre de remplacer l'ID utilisateur sur la page d'accueil Instagram",
  661. },
  662. default: true,
  663. event: instagram_Homepage_Event,
  664. },
  665. },
  666. });
  667. init_Instagram(note_obj);
  668. })();