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

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

当前为 2020-09-17 提交的版本,查看 最新版本

  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://www.sailboatweb.com
  11. // @icon data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiBhcmlhLWxhYmVsbGVkYnk9Im5ld0ljb25UaXRsZSIgc3Ryb2tlPSJyZ2JhKDI5LDE2MSwyNDIsMS4wMCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgZmlsbD0ibm9uZSIgY29sb3I9InJnYmEoMjksMTYxLDI0MiwxLjAwKSI+IDx0aXRsZSBpZD0ibmV3SWNvblRpdGxlIj5OZXc8L3RpdGxlPiA8cGF0aCBkPSJNMTkgMTRWMjJIMi45OTk5N1Y0SDEzIi8+IDxwYXRoIGQ9Ik0xNy40NjA4IDQuMDM5MjFDMTguMjQxOCAzLjI1ODE3IDE5LjUwODIgMy4yNTgxNiAyMC4yODkyIDQuMDM5MjFMMjAuOTYwOCA0LjcxMDc5QzIxLjc0MTggNS40OTE4NCAyMS43NDE4IDYuNzU4MTcgMjAuOTYwOCA3LjUzOTIxTDExLjU4NTggMTYuOTE0MkMxMS4yMTA3IDE3LjI4OTMgMTAuNzAyIDE3LjUgMTAuMTcxNiAxNy41TDcuNSAxNy41TDcuNSAxNC44Mjg0QzcuNSAxNC4yOTggNy43MTA3MSAxMy43ODkzIDguMDg1NzkgMTMuNDE0MkwxNy40NjA4IDQuMDM5MjFaIi8+IDxwYXRoIGQ9Ik0xNi4yNSA1LjI1TDE5Ljc1IDguNzUiLz4gPC9zdmc+
  12. // @version 5.2.0
  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. // @include http*://*veryins.com/*
  26. // @include http*://*inswanghong.xyz/*
  27. // @include http*://*ins89.com/*
  28. // @require https://cdn.jsdelivr.net/npm/arrive@2.4.1/minified/arrive.min.js
  29. // @require https://cdn.jsdelivr.net/npm/vue@2.6.11/dist/vue.min.js
  30. // @require https://greasyfork.org/scripts/408454-note-obj/code/Note_Obj.js?version=848809
  31. // @grant GM_info
  32. // @grant GM.info
  33. // @grant GM_getValue
  34. // @grant GM.getValue
  35. // @grant GM_setValue
  36. // @grant GM.setValue
  37. // @grant GM_deleteValue
  38. // @grant GM.deleteValue
  39. // @grant GM_listValues
  40. // @grant GM.listValues
  41. // @grant GM_openInTab
  42. // @grant GM.openInTab
  43. // @grant GM_registerMenuCommand
  44. // @grant GM_unregisterMenuCommand
  45. // @grant GM_addValueChangeListener
  46. // @grant GM_removeValueChangeListener
  47. // ==/UserScript==
  48.  
  49. (async function() {
  50. 'use strict';
  51. const INS_ICON = {
  52. 'NOTE_BLACK': 'url(data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiBhcmlhLWxhYmVsbGVkYnk9Im5ld0ljb25UaXRsZSIgc3Ryb2tlPSJyZ2IoMzgsIDM4LCAzOCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgZmlsbD0ibm9uZSIgY29sb3I9InJnYigzOCwgMzgsIDM4KSI+IDx0aXRsZSBpZD0ibmV3SWNvblRpdGxlIj5OZXc8L3RpdGxlPiA8cGF0aCBkPSJNMTkgMTRWMjJIMi45OTk5N1Y0SDEzIi8+IDxwYXRoIGQ9Ik0xNy40NjA4IDQuMDM5MjFDMTguMjQxOCAzLjI1ODE3IDE5LjUwODIgMy4yNTgxNiAyMC4yODkyIDQuMDM5MjFMMjAuOTYwOCA0LjcxMDc5QzIxLjc0MTggNS40OTE4NCAyMS43NDE4IDYuNzU4MTcgMjAuOTYwOCA3LjUzOTIxTDExLjU4NTggMTYuOTE0MkMxMS4yMTA3IDE3LjI4OTMgMTAuNzAyIDE3LjUgMTAuMTcxNiAxNy41TDcuNSAxNy41TDcuNSAxNC44Mjg0QzcuNSAxNC4yOTggNy43MTA3MSAxMy43ODkzIDguMDg1NzkgMTMuNDE0MkwxNy40NjA4IDQuMDM5MjFaIi8+IDxwYXRoIGQ9Ik0xNi4yNSA1LjI1TDE5Ljc1IDguNzUiLz4gPC9zdmc+)',
  53. 'SERACH_BLUE': 'url(data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjI0cHgiIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiBhcmlhLWxhYmVsbGVkYnk9InNlYXJjaEljb25UaXRsZSIgc3Ryb2tlPSJyZ2JhKDI5LDE2MSwyNDIsMS4wMCkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InNxdWFyZSIgc3Ryb2tlLWxpbmVqb2luPSJtaXRlciIgZmlsbD0ibm9uZSIgY29sb3I9InJnYmEoMjksMTYxLDI0MiwxLjAwKSI+IDx0aXRsZSBpZD0ic2VhcmNoSWNvblRpdGxlIj5TZWFyY2g8L3RpdGxlPiA8cGF0aCBkPSJNMTQuNDEyMTEyMiwxNC40MTIxMTIyIEwyMCwyMCIvPiA8Y2lyY2xlIGN4PSIxMCIgY3k9IjEwIiByPSI2Ii8+IDwvc3ZnPg==)'
  54. };
  55. const INS_STYLE = `
  56. .note-obj-ins-font-blue-color {
  57. color: #336699;
  58. }
  59. .note-obj-ins-background-box {
  60. display: inline-block;
  61. align-items: center;
  62. white-space: nowrap;
  63. border-radius: 50px;
  64. padding: 0px 10px;
  65. background-color: #336699;
  66. color: #fff;
  67. }
  68. .note-obj-ins-add-btn {
  69. background-image: ${INS_ICON.NOTE_BLACK};
  70. background-size: 24px;
  71. background-repeat: no-repeat;
  72. background-position: center;
  73. margin-left: 5px;
  74. cursor: pointer;
  75. width: 24px;
  76. height: 24px;
  77. }
  78. .note-obj-ins-homepage-btn {
  79. margin-top: 8px;
  80. }
  81. .note-obj-ins-userpage-btn {
  82. margin-top: 2px;
  83. }
  84. .note-obj-ins-userpage-tag {
  85. display: block;
  86. font-size: 20px;
  87. margin-bottom: 20px;
  88. white-space: nowrap;
  89. }
  90. .note-obj-ins-mobile-search-button {
  91. background-image: ${INS_ICON.SERACH_BLUE};
  92. background-size: 24px;
  93. background-repeat: no-repeat;
  94. background-position: center;
  95. cursor: pointer;
  96. min-width: 0px;
  97. height: 100%;
  98. flex: 1 1 auto;
  99. }
  100. .note-obj-ins-font-bold {
  101. font-weight: bold;
  102. }
  103. .note-obj-veryins-blue-tag {
  104. background-color: #3c81df;
  105. color: #fff;
  106. display: inline-flex;
  107. align-items: center;
  108. padding: 0px 10px;
  109. white-space: nowrap;
  110. line-height: 100%;
  111. border-radius: 50px;
  112. padding: 2px 10px;
  113. }
  114. .note-obj-veryins-userpage-btn {
  115. display: inline-block;
  116. vertical-align: middle;
  117. }
  118. `;
  119. var selector = {
  120. 'body': 'body',
  121. 'root': '#react-root',
  122. 'search': {
  123. 'frame': '.LWmhU'
  124. },
  125. 'homepage': {
  126. 'article': 'article',
  127. 'id': '.e1e1d a',
  128. 'id_shell': '.e1e1d',
  129. 'icon': 'span.wmtNn',
  130. 'comment_id': '.FPmhX',
  131. 'comment_at': '._8Pl3R .notranslate'
  132. },
  133. 'homepage_stories': {
  134. 'id': '.eebAO',
  135. 'id_shell': '.Fd_fQ',
  136. },
  137. 'homepage_recommend': {
  138. 'id': '.fDxYl a'
  139. },
  140. 'user_page': {
  141. 'frame': '.zwlfE',
  142. 'id': '.KV-D4',
  143. 'bar': '.AFWDX',
  144. 'box': '.nZSzR',
  145. 'common': 'span._32eiM',
  146. 'suggest': '.Qj3-a',
  147. 'info_at': '.notranslate',
  148. 'user_name': '.-vDIg .rhpdm'
  149. },
  150. 'stories': {
  151. 'id': '.FPmhX',
  152. 'id_shell': '.yn6BW'
  153. },
  154. 'watch_list': {
  155. 'initial_item': '.isgrP li',
  156. 'later_item': '.d7ByH',
  157. 'id': 'a.FPmhX'
  158. },
  159. 'dialog': {
  160. 'frame': '._2dDPU article',
  161. 'comment_id': '.EtaWk .ZIAjV',
  162. 'comment_at': '.EtaWk .notranslate'
  163. },
  164. 'request': {
  165. 'follow': '.yrJyr'
  166. },
  167. 'mobile': {
  168. 'bottom_bar': '.BvyAW'
  169. },
  170. 'suggest': {
  171. 'user': '.FPmhX.notranslate.MBL3Z'
  172. }
  173. };
  174. function instagram_Change_Event(note_obj, user_id = null) {
  175. for (let article of document.querySelectorAll(selector.homepage.article)) {
  176. let article_user = article.querySelector(selector.homepage.id);
  177. if (article_user) {
  178. let article_user_id = Note_Obj.fn.getUserIdFromLink(article_user.href);
  179. (! user_id || user_id == article_user_id) && note_obj.handler(article_user_id, article_user, null, {
  180. 'add': note_obj.getConfig().other.replaceHomepageID ? null : 'span',
  181. 'classname': note_obj.getConfig().other.replaceHomepageID ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  182. 'title': note_obj.getConfig().other.replaceHomepageID
  183. });
  184. }
  185. for (let comment of article.querySelectorAll(selector.homepage.comment_id)) {
  186. let comment_id = Note_Obj.fn.getUserIdFromLink(comment.href);
  187. (! user_id || user_id == comment_id) && note_obj.handler(comment_id, comment, null, {
  188. 'classname': 'note-obj-ins-font-blue-color'
  189. });
  190. }
  191. for (let comment_at of article.querySelectorAll(selector.homepage.comment_at)) {
  192. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  193. (! user_id || user_id == comment_at_id) && note_obj.handler(comment_at_id, comment_at, null, {
  194. 'symbol': {
  195. 'prefix': '@'
  196. },
  197. 'title': true,
  198. 'classname': 'note-obj-ins-font-blue-color'
  199. });
  200. }
  201. for (let pic_comment_user of (article.querySelectorAll(selector.dialog.comment_id))) {
  202. let pic_comment_id = Note_Obj.fn.getUserIdFromLink(pic_comment_user.href);
  203. (! user_id || user_id == pic_comment_id) && note_obj.handler(pic_comment_id, pic_comment_user, null, {
  204. 'title': true,
  205. 'classname': 'note-obj-ins-font-blue-color'
  206. });
  207. }
  208. for (let pic_comment_at of article.querySelectorAll(selector.dialog.comment_at)) {
  209. if (! pic_comment_at.classList.contains(selector.homepage.comment_id.replace(/^\.|\s+.*$/g, ''))) {
  210. let pic_comment_at_id = Note_Obj.fn.getUserIdFromLink(pic_comment_at.href);
  211. (! user_id || user_id == pic_comment_at_id) && note_obj.handler(pic_comment_at_id, pic_comment_at, null, {
  212. 'symbol': {
  213. 'prefix': '@'
  214. },
  215. 'title': true,
  216. 'classname': 'note-obj-ins-font-blue-color'
  217. });
  218. }
  219. }
  220. }
  221. for (let homepage_stories of document.querySelectorAll(selector.homepage_stories.id_shell)) {
  222. if (homepage_stories.querySelector(selector.homepage_stories.id)) {
  223. let homepage_stories_id = homepage_stories.querySelector(selector.homepage_stories.id).textContent;
  224. if (! user_id || user_id == homepage_stories_id) {
  225. homepage_stories.title = note_obj.getUserTag(homepage_stories_id);
  226. }
  227. }
  228. }
  229. for (let homepage_recommend of document.querySelectorAll(selector.homepage_recommend.id)) {
  230. let homepage_recommend_id = note_obj.getUserIdFromLink(homepage_recommend.href);
  231. (! user_id || user_id == homepage_recommend_id) && note_obj.handler(homepage_recommend_id, homepage_recommend, null, {
  232. 'classname': 'note-obj-ins-font-blue-color'
  233. });
  234. }
  235. for (let user_page of document.querySelectorAll(selector.user_page.frame)) {
  236. if (user_page.querySelector(selector.user_page.id)) {
  237. let user_page_id = user_page.querySelector(selector.user_page.id).textContent;
  238. if (! user_id || user_id == user_page_id) {
  239. let user_page_tag = user_page.querySelector('.note-obj-user-tag');
  240. user_page_tag && user_page_tag.remove();
  241. note_obj.judgeUsers(user_page_id) && user_page.querySelector(selector.user_page.box).after(note_obj.createNoteTag(user_page_id, {
  242. 'secondaryColor': false,
  243. 'offsetWidth': -20
  244. }, 'div', ['note-obj-ins-userpage-tag', 'note-obj-ins-font-blue-color', 'note-obj-ins-font-bold']));
  245. }
  246. }
  247. for (let common_user of user_page.querySelectorAll(selector.user_page.common)) {
  248. let common_user_id = common_user.textContent;
  249. if (! user_id || user_id == common_user_id) {
  250. if (note_obj.judgeUsers(common_user_id)) {
  251. common_user.title = note_obj.getUserTag(common_user_id);
  252. if (note_obj.getShowNoteColorConfig()) {
  253. common_user.style.setProperty('color', note_obj.getPrimaryColor(common_user_id), 'important');
  254. } else {
  255. common_user.style.setProperty('color', '');
  256. }
  257. common_user.classList.add('note-obj-ins-font-blue-color');
  258. } else {
  259. common_user.title = '',
  260. common_user.style.setProperty('color', '');
  261. common_user.classList.remove('note-obj-ins-font-blue-color');
  262. }
  263. }
  264. }
  265. for (let info_at_user of user_page.querySelectorAll(selector.user_page.info_at)) {
  266. let info_at_user_id = Note_Obj.fn.getUserIdFromLink(info_at_user.href);
  267. (! user_id || user_id == info_at_user_id) && note_obj.handler(info_at_user_id, info_at_user, null, {
  268. 'symbol': {
  269. 'prefix': '@'
  270. },
  271. 'classname': 'note-obj-ins-font-blue-color',
  272. 'title': true
  273. });
  274. }
  275. }
  276. for (let stories_shell of document.querySelectorAll(selector.stories.id_shell)) {
  277. let stories = stories_shell.querySelector(selector.stories.id);
  278. if (stories) {
  279. let stories_user_id = Note_Obj.fn.getUserIdFromLink(stories.href);
  280. (! user_id || user_id == stories_user_id) && note_obj.handler(stories_user_id, stories, null, {
  281. 'classname': 'note-obj-ins-font-blue-color'
  282. });
  283. }
  284. }
  285. for (let initial of document.querySelectorAll(selector.watch_list.initial_item)) {
  286. let initial_item = initial.querySelector(selector.watch_list.id);
  287. if (initial_item) {
  288. let initial_item_id = Note_Obj.fn.getUserIdFromLink(initial_item.href);
  289. (! user_id || user_id == initial_item_id) && note_obj.handler(initial_item_id, initial_item, null, {
  290. 'classname': 'note-obj-ins-font-blue-color'
  291. });
  292. }
  293. }
  294. for (let later of document.querySelectorAll(selector.watch_list.later_item)) {
  295. let later_item = later.querySelector(selector.watch_list.id);
  296. if (later_item) {
  297. let later_item_id = Note_Obj.fn.getUserIdFromLink(later_item.href);
  298. (! user_id || user_id == later_item_id) && note_obj.handler(later_item_id, later_item, null, {
  299. 'classname': 'note-obj-ins-font-blue-color'
  300. });
  301. }
  302. }
  303. for (let dialog of document.querySelectorAll(selector.dialog.frame)) {
  304. let dialog_a = dialog.querySelector(selector.homepage.id);
  305. if (dialog_a) {
  306. let dialog_a_id = Note_Obj.fn.getUserIdFromLink(dialog_a.href);
  307. (! user_id || user_id == dialog_a_id) && note_obj.handler(dialog_a_id, dialog_a, null, {
  308. 'title': true,
  309. 'classname': 'note-obj-ins-font-blue-color'
  310. });
  311. }
  312. for (let like of dialog.querySelectorAll(selector.homepage.comment_id)) {
  313. let like_id = Note_Obj.fn.getUserIdFromLink(like.href);
  314. (! user_id || user_id == like_id) && note_obj.judgeUsers(like_id) && note_obj.handler(like_id, like, null, {
  315. 'classname': 'note-obj-ins-font-blue-color'
  316. });
  317. }
  318. for (let comment_user of dialog.querySelectorAll(selector.dialog.comment_id)) {
  319. let comment_id = Note_Obj.fn.getUserIdFromLink(comment_user.href);
  320. (! user_id || user_id == comment_id) && note_obj.handler(comment_id, comment_user, null, {
  321. 'classname': 'note-obj-ins-font-blue-color',
  322. 'title': true
  323. });
  324. }
  325. for (let comment_at of dialog.querySelectorAll(selector.dialog.comment_at)) {
  326. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  327. (! user_id || user_id == comment_at_id) && note_obj.handler(comment_at_id, comment_at, null, {
  328. 'symbol': {
  329. 'prefix': '@'
  330. },
  331. 'classname': 'note-obj-ins-font-blue-color',
  332. 'title': true
  333. });
  334. }
  335. }
  336. for (let follow of document.querySelectorAll(selector.request.follow)) {
  337. let follow_user_id = Note_Obj.fn.getUserIdFromLink(follow.href);
  338. (! user_id || user_id == follow_user_id) && note_obj.handler(follow_user_id, follow, null, {
  339. 'classname': 'note-obj-ins-font-blue-color'
  340. });
  341. }
  342. for (let suggest_user of document.querySelectorAll(selector.suggest.user)) {
  343. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest_user.href);
  344. (! user_id || user_id == suggest_user_id) && note_obj.handler(suggest_user_id, suggest_user, null, {
  345. 'classname': 'note-obj-ins-font-blue-color'
  346. });
  347. }
  348. for (let suggest of document.querySelectorAll(selector.user_page.suggest)) {
  349. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest.href);
  350. (! user_id || user_id == suggest_user_id) && note_obj.handler(suggest_user_id, suggest, null, {
  351. 'classname': 'note-obj-ins-font-blue-color'
  352. });
  353. }
  354. }
  355. function veryins_Change_Event(note_obj, id = null) {
  356. document.querySelectorAll('#list .item').forEach(item => {
  357. let user = item.querySelector('.item-body > div > a');
  358. if (user) {
  359. let user_id = Note_Obj.fn.getUserIdFromLink(user.href);
  360. (! id || id == user_id) && note_obj.handler(user_id, user, null, {
  361. 'add': 'span',
  362. 'classname': 'note-obj-veryins-blue-tag'
  363. });
  364. }
  365. });
  366. document.querySelectorAll('.row.header').forEach(item => {
  367. let user = item.querySelector('section > div > div');
  368. if (user) {
  369. let user_id = user.querySelector('#username') && user.querySelector('#username').textContent;
  370. (! id || id == user_id) && user.querySelector('div > strong') && note_obj.handler(user_id, user.querySelector('div > strong'), null, {
  371. 'add': 'span',
  372. 'classname': 'note-obj-veryins-blue-tag'
  373. });
  374. }
  375. });
  376. document.querySelectorAll('.img-container .article .caption-header a').forEach(item => {
  377. let user_id = Note_Obj.fn.getUserIdFromLink(item.href, value => /^[^/]+$/i.test(value));
  378. (!id || id == user_id) && note_obj.handler(user_id, item, null, {
  379. 'add': 'span',
  380. 'classname': 'note-obj-veryins-blue-tag'
  381. });
  382. });
  383. }
  384. function inswanghong_Change_Event(note_obj, id = null) {
  385. document.querySelectorAll('#tiles .info').forEach(item => {
  386. let user_id = item.title || item.textContent;
  387. (! id || id == user_id) && note_obj.handler(user_id, item, null, {
  388. 'title': true,
  389. 'classname': 'note-obj-ins-font-blue-color'
  390. });
  391. });
  392. }
  393. function ins89_Change_Event(note_obj, id = null) {
  394. document.querySelectorAll('.container .row.pt-2 .card').forEach(item => {
  395. let card_header_user = item.querySelector('.card-header .username');
  396. if (card_header_user) {
  397. let card_header_user_id = Note_Obj.fn.getUserIdFromLink(card_header_user.href);
  398. (! id || id == card_header_user_id) && note_obj.handler(card_header_user_id, card_header_user, null, {
  399. 'title': true
  400. });
  401. let card_body_user = item.querySelector('.card-body .username');
  402. if (card_body_user) {
  403. (! id || id == card_header_user_id) && note_obj.handler(card_header_user_id, card_body_user, null, {
  404. 'title': true
  405. });
  406. }
  407. }
  408. });
  409. document.querySelectorAll('.profile-info-pannel .container').forEach(item => {
  410. let profile_avatar = item.querySelector('.profile-avatar a');
  411. if (profile_avatar) {
  412. let user_id = Note_Obj.fn.getUserIdFromLink(profile_avatar.href);
  413. if (! id || id == user_id) {
  414. let username_bar = item.querySelector('.username-bar h1');
  415. username_bar && note_obj.handler(user_id, username_bar, null, {
  416. 'title': true
  417. });
  418. }
  419. }
  420. });
  421. document.querySelectorAll('.postComponent .card .status-username .username .username-link').forEach(item => {
  422. let user_id = item.textContent;
  423. (! id || id == user_id) && note_obj.handler(user_id, item, null);
  424. });
  425. document.querySelectorAll('.modal-content .blogger-list .concern .concern-box').forEach(item => {
  426. let user_a = item.querySelector('a');
  427. if (user_a) {
  428. let user_id = Note_Obj.fn.getUserIdFromLink(user_a.href);
  429. let concern_text = item.querySelector('.concern-text .text-name');
  430. concern_text && (! id || id == user_id) && note_obj.handler(user_id, concern_text, null);
  431. }
  432. });
  433. }
  434. function instagram_Homepage_Event(newValue, oldValue) {
  435. if (newValue != oldValue) {
  436. for (let article of document.querySelectorAll(selector.homepage.article)) {
  437. let article_user = article.querySelector(selector.homepage.id);
  438. if (article_user) {
  439. let article_user_id = Note_Obj.fn.getUserIdFromLink(article_user.href);
  440. note_obj.handler(article_user_id, article_user, null, {
  441. 'add': oldValue ? null : 'span',
  442. 'classname': oldValue ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  443. 'title': oldValue,
  444. 'restore': true
  445. });
  446. note_obj.handler(article_user_id, article_user, null, {
  447. 'add': newValue ? null : 'span',
  448. 'classname': newValue ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  449. 'title': newValue
  450. });
  451. }
  452. }
  453. }
  454. }
  455. function init_Instagram(note_obj) {
  456. let arrive_option = {
  457. 'fireOnAttributesModification': true,
  458. 'existing': true
  459. };
  460. Note_Obj.fn.isMobilePage() && document.querySelector(selector.root).arrive(selector.mobile.bottom_bar, arrive_option, item => item.appendChild(note_obj.createSearchButton('note-obj-ins-mobile-search-button')));
  461. document.querySelector(selector.root).arrive(selector.homepage.article, arrive_option, article => {
  462. let article_user = article.querySelector(selector.homepage.id);
  463. if (article_user) {
  464. let article_user_id = Note_Obj.fn.getUserIdFromLink(article_user.href);
  465. note_obj.judgeUsers(article_user_id) && note_obj.handler(article_user_id, article_user, null, {
  466. 'add': note_obj.getConfig().other.replaceHomepageID ? null : 'span',
  467. 'classname': note_obj.getConfig().other.replaceHomepageID ? 'note-obj-ins-font-blue-color' : 'note-obj-ins-background-box',
  468. 'title': note_obj.getConfig().other.replaceHomepageID
  469. });
  470. article.querySelector(selector.homepage.icon) && article.querySelector(selector.homepage.icon).insertAdjacentElement('beforebegin', note_obj.createNoteBtn(article_user_id, null, ['note-obj-ins-add-btn', 'note-obj-ins-homepage-btn']));
  471. }
  472. for (let comment of article.querySelectorAll(selector.homepage.comment_id)) {
  473. let comment_id = Note_Obj.fn.getUserIdFromLink(comment.href);
  474. note_obj.judgeUsers(comment_id) && note_obj.handler(comment_id, comment, null, {
  475. 'classname': 'note-obj-ins-font-blue-color'
  476. });
  477. }
  478. article.arrive(selector.homepage.comment_at, arrive_option, comment_at => {
  479. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  480. note_obj.judgeUsers(comment_at_id) && note_obj.handler(comment_at_id, comment_at, null, {
  481. 'symbol': {
  482. 'prefix': '@'
  483. },
  484. 'title': true,
  485. 'classname': 'note-obj-ins-font-blue-color'
  486. });
  487. });
  488. article.arrive(selector.dialog.comment_id, arrive_option, pic_comment_user => {
  489. let pic_comment_id = Note_Obj.fn.getUserIdFromLink(pic_comment_user.href);
  490. note_obj.judgeUsers(pic_comment_id) && note_obj.handler(pic_comment_id, pic_comment_user, null, {
  491. 'title': true,
  492. 'classname': 'note-obj-ins-font-blue-color'
  493. });
  494. });
  495. article.arrive(selector.dialog.comment_at, arrive_option, pic_comment_at => {
  496. if (! pic_comment_at.classList.contains(selector.homepage.comment_id.replace(/^\.|\s+.*$/g, ''))) {
  497. let pic_comment_at_id = Note_Obj.fn.getUserIdFromLink(pic_comment_at.href);
  498. note_obj.judgeUsers(pic_comment_at_id) && note_obj.handler(pic_comment_at_id, pic_comment_at, null, {
  499. 'symbol': {
  500. 'prefix': '@'
  501. },
  502. 'title': true,
  503. 'classname': 'note-obj-ins-font-blue-color'
  504. });
  505. }
  506. });
  507. });
  508. document.querySelector(selector.root).arrive(selector.homepage_stories.id_shell, arrive_option, homepage_stories => {
  509. if (homepage_stories.querySelector(selector.homepage_stories.id)) {
  510. let homepage_stories_id = homepage_stories.querySelector(selector.homepage_stories.id).textContent;
  511. if (note_obj.judgeUsers(homepage_stories_id)) {
  512. homepage_stories.title = note_obj.getUserTag(homepage_stories_id);
  513. }
  514. }
  515. });
  516. document.querySelector(selector.root).arrive(selector.homepage_recommend.id, arrive_option, homepage_recommend => {
  517. let homepage_recommend_id = note_obj.getUserIdFromLink(homepage_recommend.href);
  518. note_obj.judgeUsers(homepage_recommend_id) && note_obj.handler(homepage_recommend_id, homepage_recommend, null, {
  519. 'classname': 'note-obj-ins-font-blue-color'
  520. });
  521. });
  522. document.querySelector(selector.root).arrive(selector.user_page.frame, arrive_option, user_page => {
  523. if (user_page.querySelector(selector.user_page.id)) {
  524. let user_page_id = user_page.querySelector(selector.user_page.id).textContent;
  525. let user_name = user_page.querySelector(selector.user_page.user_name);
  526. let user_name_text = '';
  527. if (user_name) {
  528. user_name_text = user_page.querySelector(selector.user_page.user_name).textContent;
  529. }
  530. user_page.querySelector(selector.user_page.bar) && user_page.querySelector(selector.user_page.bar).after(note_obj.createNoteBtn(user_page_id, user_name_text, ['note-obj-ins-add-btn', 'note-obj-ins-userpage-btn']));
  531. note_obj.judgeUsers(user_page_id) && user_page.querySelector(selector.user_page.box).after(note_obj.createNoteTag(user_page_id, {
  532. 'secondaryColor': false,
  533. 'offsetWidth': -20
  534. }, 'div', ['note-obj-ins-userpage-tag', 'note-obj-ins-font-blue-color', 'note-obj-ins-font-bold'], user_name_text));
  535. }
  536. for (let common_user of user_page.querySelectorAll(selector.user_page.common)) {
  537. let common_user_id = common_user.textContent;
  538. if (note_obj.judgeUsers(common_user_id)) {
  539. common_user.title = note_obj.getUserTag(common_user_id);
  540. note_obj.getShowNoteColorConfig() && common_user.style.setProperty('color', note_obj.getPrimaryColor(common_user_id), 'important');
  541. common_user.classList.add('note-obj-ins-font-blue-color');
  542. }
  543. }
  544. for (let info_at_user of user_page.querySelectorAll(selector.user_page.info_at)) {
  545. let info_at_user_id = Note_Obj.fn.getUserIdFromLink(info_at_user.href);
  546. note_obj.judgeUsers(info_at_user_id) && note_obj.handler(info_at_user_id, info_at_user, null, {
  547. 'symbol': {
  548. 'prefix': '@'
  549. },
  550. 'classname': 'note-obj-ins-font-blue-color',
  551. 'title': true
  552. });
  553. }
  554. });
  555. document.querySelector(selector.root).arrive(selector.stories.id_shell, arrive_option, stories_shell => {
  556. let stories = stories_shell.querySelector(selector.stories.id);
  557. if (stories) {
  558. let stories_user_id = Note_Obj.fn.getUserIdFromLink(stories.href);
  559. note_obj.judgeUsers(stories_user_id) && note_obj.handler(stories_user_id, stories, null, {
  560. 'classname': 'note-obj-ins-font-blue-color'
  561. });
  562. }
  563. });
  564. document.querySelector(selector.body).arrive(selector.watch_list.initial_item, arrive_option, initial => {
  565. let initial_item = initial.querySelector(selector.watch_list.id);
  566. if (initial_item) {
  567. let initial_item_id = Note_Obj.fn.getUserIdFromLink(initial_item.href);
  568. note_obj.judgeUsers(initial_item_id) && note_obj.handler(initial_item_id, initial_item, null, {
  569. 'classname': 'note-obj-ins-font-blue-color'
  570. });
  571. }
  572. });
  573. document.querySelector(selector.body).arrive(selector.watch_list.later_item, arrive_option, later => {
  574. let later_item = later.querySelector(selector.watch_list.id);
  575. if (later_item) {
  576. let later_item_id = Note_Obj.fn.getUserIdFromLink(later_item.href);
  577. note_obj.judgeUsers(later_item_id) && note_obj.handler(later_item_id, later_item, null, {
  578. 'classname': 'note-obj-ins-font-blue-color'
  579. });
  580. }
  581. });
  582. document.querySelector(selector.body).arrive(selector.dialog.frame, arrive_option, dialog => {
  583. let dialog_a = dialog.querySelector(selector.homepage.id);
  584. if (dialog_a) {
  585. let dialog_a_id = Note_Obj.fn.getUserIdFromLink(dialog_a.href);
  586. note_obj.judgeUsers(dialog_a_id) && note_obj.handler(dialog_a_id, dialog_a, null, {
  587. 'title': true,
  588. 'classname': 'note-obj-ins-font-blue-color'
  589. });
  590. dialog.querySelector(selector.homepage.icon) && dialog.querySelector(selector.homepage.icon).insertAdjacentElement('beforebegin', note_obj.createNoteBtn(dialog_a_id, null, ['note-obj-ins-add-btn', 'note-obj-ins-homepage-btn']));
  591. }
  592. for (let like of dialog.querySelectorAll(selector.homepage.comment_id)) {
  593. let like_id = Note_Obj.fn.getUserIdFromLink(like.href);
  594. note_obj.judgeUsers(like_id) && note_obj.handler(like_id, like, null, {
  595. 'classname': 'note-obj-ins-font-blue-color'
  596. });
  597. }
  598. dialog.arrive(selector.dialog.comment_id, arrive_option, comment_user => {
  599. let comment_id = Note_Obj.fn.getUserIdFromLink(comment_user.href);
  600. note_obj.judgeUsers(comment_id) && note_obj.handler(comment_id, comment_user, null, {
  601. 'classname': 'note-obj-ins-font-blue-color',
  602. 'title': true
  603. });
  604. });
  605. dialog.arrive(selector.dialog.comment_at, arrive_option, comment_at => {
  606. let comment_at_id = Note_Obj.fn.getUserIdFromLink(comment_at.href);
  607. note_obj.judgeUsers(comment_at_id) && note_obj.handler(comment_at_id, comment_at, null, {
  608. 'symbol': {
  609. 'prefix': '@'
  610. },
  611. 'classname': 'note-obj-ins-font-blue-color',
  612. 'title': true
  613. });
  614. });
  615. });
  616. document.querySelector(selector.root).arrive(selector.request.follow, arrive_option, follow => {
  617. let follow_user_id = Note_Obj.fn.getUserIdFromLink(follow.href);
  618. note_obj.judgeUsers(follow_user_id) && note_obj.handler(follow_user_id, follow, null, {
  619. 'classname': 'note-obj-ins-font-blue-color'
  620. });
  621. });
  622. document.querySelector(selector.root).arrive(selector.suggest.user, arrive_option, suggest_user => {
  623. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest_user.href);
  624. note_obj.judgeUsers(suggest_user_id) && note_obj.handler(suggest_user_id, suggest_user, null, {
  625. 'classname': 'note-obj-ins-font-blue-color'
  626. });
  627. });
  628. document.querySelector(selector.root).arrive(selector.user_page.suggest, arrive_option, suggest => {
  629. let suggest_user_id = Note_Obj.fn.getUserIdFromLink(suggest.href);
  630. note_obj.judgeUsers(suggest_user_id) && note_obj.handler(suggest_user_id, suggest, null, {
  631. 'classname': 'note-obj-ins-font-blue-color'
  632. });
  633. });
  634. }
  635. function init_Veryins(note_obj) {
  636. let arrive_option = {
  637. 'fireOnAttributesModification': true,
  638. 'existing': true
  639. };
  640. document.getElementById('list') && document.getElementById('list').arrive('.item', arrive_option, item => {
  641. let user = item.querySelector('.item-body > div > a');
  642. if (user) {
  643. let user_id = Note_Obj.fn.getUserIdFromLink(user.href);
  644. note_obj.judgeUsers(user_id) && note_obj.handler(user_id, user, null, {
  645. 'add': 'span',
  646. 'classname': 'note-obj-veryins-blue-tag'
  647. }, user.textContent);
  648. }
  649. });
  650. document.querySelectorAll('.row.header').forEach(item => {
  651. let user = item.querySelector('section > div > div');
  652. if (user) {
  653. let user_id = user.querySelector('#username') && user.querySelector('#username').textContent;
  654. let user_name = user.querySelector('#username') && user.querySelector('#username').dataset.fullname;
  655. user.querySelector('div > strong') && note_obj.judgeUsers(user_id) && note_obj.handler(user_id, user.querySelector('div > strong'), null, {
  656. 'add': 'span',
  657. 'classname': 'note-obj-veryins-blue-tag'
  658. }, user_name);
  659. user.querySelector('#similar') && user.querySelector('#similar').after(note_obj.createNoteBtn(user_id, user_name, ['note-obj-ins-add-btn', 'note-obj-veryins-userpage-btn']));
  660. }
  661. });
  662. document.querySelector('.img-container .article .caption-header') && document.querySelector('.img-container .article .caption-header').arrive('a', arrive_option, item => {
  663. let user_id = Note_Obj.fn.getUserIdFromLink(item.href, value => /^[^/]+$/i.test(value));
  664. note_obj.judgeUsers(user_id) && note_obj.handler(user_id, item, null, {
  665. 'add': 'span',
  666. 'classname': 'note-obj-veryins-blue-tag'
  667. }, item.textContent);
  668. });
  669. }
  670. function init_Inswanghong(note_obj) {
  671. document.querySelectorAll('#tiles .info').forEach(item => {
  672. let user_id = item.textContent;
  673. note_obj.judgeUsers(user_id) && note_obj.handler(user_id, item, null, {
  674. 'title': true,
  675. 'classname': 'note-obj-ins-font-blue-color'
  676. });
  677. });
  678. }
  679. function init_Ins89(note_obj) {
  680. let arrive_option = {
  681. 'fireOnAttributesModification': true,
  682. 'existing': true
  683. };
  684. document.querySelector('.container .row.pt-2') && document.querySelector('.container .row.pt-2').arrive('.card', arrive_option, item => {
  685. let card_header_user = item.querySelector('.card-header .username');
  686. if (card_header_user) {
  687. let card_header_user_id = Note_Obj.fn.getUserIdFromLink(card_header_user.href);
  688. note_obj.judgeUsers(card_header_user_id) && note_obj.handler(card_header_user_id, card_header_user, null, {
  689. 'title': true
  690. });
  691. let card_body_user = item.querySelector('.card-body .username');
  692. if (card_body_user) {
  693. note_obj.judgeUsers(card_header_user_id) && note_obj.handler(card_header_user_id, card_body_user, null, {
  694. 'title': true
  695. });
  696. }
  697. }
  698. });
  699. document.querySelectorAll('.profile-info-pannel .container').forEach(item => {
  700. let profile_avatar = item.querySelector('.profile-avatar a');
  701. if (profile_avatar) {
  702. let user_id = Note_Obj.fn.getUserIdFromLink(profile_avatar.href);
  703. if (note_obj.judgeUsers(user_id)) {
  704. let username_bar = item.querySelector('.username-bar h1');
  705. username_bar && note_obj.handler(user_id, username_bar, null, {
  706. 'title': true
  707. });
  708. }
  709. let fa_ellipsis_h = item.querySelector('.fa-ellipsis-h');
  710. fa_ellipsis_h && fa_ellipsis_h.after(note_obj.createNoteBtn(user_id, null, ['note-obj-ins-add-btn', 'note-obj-veryins-userpage-btn']));
  711. }
  712. });
  713. document.querySelectorAll('.postComponent .card .status-username .username .username-link').forEach(item => {
  714. let user_id = item.textContent;
  715. note_obj.judgeUsers(user_id) && note_obj.handler(user_id, item, null);
  716. });
  717. document.querySelector('.modal-content .blogger-list') && document.querySelector('.modal-content .blogger-list').arrive('.concern .concern-box', arrive_option, item => {
  718. let user_a = item.querySelector('a');
  719. if (user_a) {
  720. let user_id = Note_Obj.fn.getUserIdFromLink(user_a.href);
  721. let concern_text = item.querySelector('.concern-text .text-name');
  722. concern_text && note_obj.judgeUsers(user_id) && note_obj.handler(user_id, concern_text, null);
  723. }
  724. });
  725. }
  726. var cur_url = location.hostname;
  727. let note_obj = new Note_Obj('myInstagramNote');
  728. await note_obj.init({
  729. 'style': INS_STYLE,
  730. 'changeEvent': (cur_url.includes('instagram.com') && instagram_Change_Event) || (cur_url.includes('veryins.com') && veryins_Change_Event) || (cur_url.includes('inswanghong.xyz') && inswanghong_Change_Event) || (cur_url.includes('ins89.com') && ins89_Change_Event),
  731. 'script': {
  732. 'author': {
  733. 'name': 'pana',
  734. 'homepage': 'https://www.sailboatweb.com/'
  735. },
  736. 'address': 'https://greasyfork.org/scripts/387871',
  737. 'updated': '2020-9-17',
  738. 'library': [
  739. {
  740. 'name': 'arrive.js',
  741. 'version': '2.4.1',
  742. 'url': 'https://github.com/uzairfarooq/arrive'
  743. }
  744. ]
  745. },
  746. 'itemClick': cur_url.includes('inswanghong.xyz') ? (key => 'https://veryins.com/' + key) : null,
  747. 'primaryColor': '#336699',
  748. 'settings': {
  749. 'replaceHomepageID': {
  750. 'type': 'checkbox',
  751. 'lang': {
  752. 'en': 'Allow to replace the user ID on the instagram homepage',
  753. 'zh_cn': '允许替换 Instagram 首页上的用户 ID',
  754. 'zh_tw': '允許替換 Instagram 首頁上的用戶 ID',
  755. 'ja': 'Instagram ホームページのユーザーIDの置き換えを許可する',
  756. 'ko': 'Instagram 첫 페이지에 있는 사용자 ID 바꾸기 허용',
  757. 'fr': 'Permettre de remplacer l\'ID utilisateur sur la page d\'accueil Instagram'
  758. },
  759. 'default': true,
  760. 'event': cur_url.includes('instagram.com') ? instagram_Homepage_Event : null
  761. }
  762. }
  763. });
  764. if (cur_url.includes('instagram.com')) {
  765. init_Instagram(note_obj);
  766. } else if (cur_url.includes('veryins.com')) {
  767. init_Veryins(note_obj);
  768. } else if (cur_url.includes('inswanghong.xyz')) {
  769. init_Inswanghong(note_obj);
  770. } else if (cur_url.includes('ins89.com')) {
  771. init_Ins89(note_obj);
  772. }
  773. })();