VK By RAM

Вернём старый дизайн вместе

当前为 2022-01-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name VK By RAM
  3. // @namespace https://greasyfork.org/ru/scripts/434514-vk-old-style-2-0
  4. // @version 3.1.4
  5. // @description Вернём старый дизайн вместе
  6. // @author RAM
  7. // @match https://*.vk.com/*
  8. // @icon https://www.google.com/s2/favicons?domain=vk.com
  9. // @license MIT
  10. // @compatible chrome
  11. // @compatible firefox
  12. // @compatible opera
  13. // @compatible safari
  14. // @compatible edge
  15. // ==/UserScript==
  16. var i,i2,vd
  17.  
  18. i=0
  19. i2=0
  20. vd=0
  21. window.onload = function() {
  22. initial();
  23. };
  24.  
  25. window.onblur = function () {
  26. var a = setInterval(title,2000);
  27. var b = setInterval(ads,2000);
  28. var c = setInterval(check,1000);
  29. clearInterval(a);
  30. clearInterval(b);
  31. clearInterval(c);
  32. }
  33.  
  34. window.onfocus = function () {
  35. setInterval(title,2000);
  36. setInterval(ads,2000);
  37. setInterval(check,1000);
  38. //fix_name();
  39. }
  40.  
  41. function initial(){
  42. console.log('Скрипт запущен');
  43. setInterval(title,2000);
  44. setInterval(ads,2000);
  45. setInterval(check,1000);
  46. fix_name();
  47. }
  48.  
  49. // Проверка
  50. function check(){
  51. check_vid();
  52. dot_check();
  53. feed_check();
  54. }
  55.  
  56. function feed_check(){
  57. if (window.location.href.includes('feed')){
  58. _class();
  59. }
  60. }
  61.  
  62. function _class(){
  63.  
  64.  
  65. KPP.add('.PostButtonReactions', function (reactions) {
  66. var count = reactions.dataset.reactionCounts;
  67. if (count && !(reactions.dataset.reactionButtonTextIsCounter)) {
  68. count = JSON.parse(count);
  69. if (!Array.isArray(count)) {
  70. count = Object.values(count)
  71. }
  72. var likes = count.reduce(function(previous, current) {
  73. return previous + current
  74. })
  75. reactions.getElementsByClassName('PostButtonReactions__title')[0].textContent = likes;
  76. }
  77. reactions.dataset.reactionButtonTextIsCounter = '1';
  78.  
  79. var target = reactions.dataset.reactionTargetObject;
  80. if (target) {
  81. reactions.setAttribute('onmouseover','Likes.showLikes(this,\'' + target + '\')')
  82. }
  83. });
  84.  
  85. var u,k
  86. var old1 = document.querySelectorAll('.like_cont.PostBottomActionLikeBtns.PostBottomActionLikeBtns--withBgButtons')
  87. for (u = 0; u < old1.length; u++) {
  88. old1[u].classList= 'like_cont';
  89. }
  90. var old2 = document.querySelectorAll('.PostButtonReactions__icon.PostButtonReactions__icon--custom.PostButtonReactions__icon--animationActive')
  91. for (k = 0;k<old2.length;k++){
  92. old2[k].style.background=`background-image: url(data:image/svg+xml;charset=utf-8,%3Csvg%20viewBox%3D%220%200%2024%2024%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22m0%200h24v24h-24z%22%20fill%3D%22none%22%2F%3E%3Cpath%20d%3D%22m17%202.9a6.43%206.43%200%200%201%206.4%206.43c0%203.57-1.43%205.36-7.45%2010l-2.78%202.16a1.9%201.9%200%200%201%20-2.33%200l-2.79-2.12c-6.05-4.68-7.45-6.47-7.45-10.04a6.43%206.43%200%200%201%206.4-6.43%205.7%205.7%200%200%201%205%203.1%205.7%205.7%200%200%201%205-3.1z%22%20fill%3D%22%23ff3347%22%2F%3E%3C%2Fsvg%3E);`
  93. }
  94. }
  95.  
  96. // Название
  97. function title(){
  98. var title
  99. title = document.querySelector('title')
  100. if (title.textContent=='Мессенджер'){
  101. title.textContent = 'Сообщения'
  102. }
  103. }
  104.  
  105. // Реклама
  106. function ads(){
  107. var ad_blocks,a
  108. ad_blocks = document.querySelectorAll('div#ads_left,[data-ad-view],div#games_catalog_header_content,.videoplayer_ads._overlay_hidden');
  109. for (a = 0; a < ad_blocks.length; a++) {
  110. ad_blocks[a].outerHTML= '';
  111. }}
  112.  
  113. // Три точки проверка
  114. function dot_check(){
  115. var prof
  116. prof = document.querySelector('a#profile_edit_act[href="edit"]');
  117. if (prof!==null){
  118. dot_prof();
  119. }
  120. }
  121.  
  122. // Три точки установка
  123. function dot_prof(){
  124. var aside,button,stats,stats_hash,stats_elem,stats_elem_parent,temp_a,regular_a,story_href,story
  125. aside = document.querySelector('.page_block.page_photo.ProfileActions>aside');
  126. stats = document.querySelector('[href*="/stats?"]')
  127. if (stats){
  128. stats_hash = stats.href
  129. }
  130.  
  131.  
  132. aside.style.display = 'none';
  133. aside.outerHTML='<aside aria-label="Действия со страницей" class="profile_aside"><div class="profile_aside_div"> <div class="profile_aside_div_div"> <div class="profile_aside_div_div_div"> <a href="edit" class="profile_aside_div_div_div_a">Редактировать</a> </div> <div class="profile_aside_div_div_div2"> <div aria-label="Действия" role="button" tabindex="0" class="profile_aside_div_div_div2_div"> <span class="profile_aside_div_div_div2_div_span">Действия</span> <span style="display:block;">&nbsp;</span> </div> <div class="profile_aside_one"> <div class="profile_aside_one_two"> <span class="profile_aside_one_two_three">Действия</span> </div> <div class="profile_aside_four"> <a href="memories" role="link" tabindex="0" class="profile_aside_four_a">Воспоминания</a><a href="" id="aside_story_archive" role="link" class="profile_aside_four_a2" tabindex="0">Архив историй</a><a role="link" tabindex="0" class="profile_aside_four_a2" data-task-click="ProfileAction/money_transfer_box" data-from="own_profile">Денежные переводы</a> </div> </div> </div> <span style="font-size:0px;clear:both;display:block;height: 0px;line-height:0;visibility:hidden;/">.</span></div> </div> </aside>'
  134. story = document.querySelector('a#aside_story_archive')
  135. story.href = window.location.pathname + '?w=stories'
  136. // Если есть статистика добавляем элемент
  137. if (stats){
  138. stats_elem_parent = document.querySelector('.profile_aside_four')
  139. stats_elem = document.createElement('a')
  140. stats_elem.classList = 'temp_a'
  141. stats_elem_parent.prepend(stats_elem)
  142. temp_a = document.querySelector('a.temp_a')
  143. temp_a.outerHTML = '<a href="" id="aside_stats" role="link" class="profile_aside_four_a2" tabindex="0">Статистика страницы</a>'
  144. regular_a = document.querySelector('a#aside_stats')
  145. regular_a.href = stats_hash
  146. }
  147.  
  148. button = document.querySelector('.profile_aside_div_div_div2')
  149. button.onclick = function() {
  150. var b
  151. b = document.querySelector('.profile_aside_div_div_div2')
  152. b.classList.toggle('atv')
  153. };
  154. }
  155.  
  156. // Меню и Имя возле иконки
  157. function fix_name(){
  158. //console.log('Фикс имени пошёл')
  159. var parentlnk = document.querySelector('div#top_profile_menu')
  160. var lnk = document.querySelector('li#l_pr a')
  161. var setlnk = document.querySelector('a#top_settings_link');
  162. var suplnk = document.querySelector('a#top_support_link');
  163. var loglnk = document.querySelector('a#top_logout_link');
  164. var name = document.querySelector('img.TopNavBtn__profileImg');
  165. var name2 = document.querySelector('a[href*="connect.vk.com"] div[style="color: var(--text_primary);"]')
  166. var name3 = document.querySelector('[style="background-color: var(--content_tint_background); border-radius: 8px; width: 254px; font-family: inherit;"]')
  167. var remove = document.querySelector('a[href*="connect.vk.com"] ')
  168. var remove2 = document.querySelectorAll('div#top_profile_menu span')
  169. var namealt = name.alt
  170. var s = document.querySelector('a#top_profile_link[aria-label="Настройки страницы"]');
  171. var q = document.createElement('div');
  172. var w = document.createElement('a');
  173. var n = document.createElement('a');
  174. var u = document.createElement('div');
  175. var k = document.createElement('div');
  176. var k2 = document.createElement('span');
  177. var b1
  178.  
  179. q.innerHTML = `<div style="padding-right:10px;display:inline-block;vertical-align:top;color:white;font-weight: 500;-webkit-font-smoothing: subpixel-antialiased;">`+namealt+`</div>`;
  180. w.className = 'top_profile_mrow'
  181. w.id = 'top_home_link'
  182. w.href = lnk.href
  183. n.className = 'top_profile_mrow'
  184. n.id = 'top_edit_link'
  185. n.href = '/edit'
  186. k2.style = 'position:absolute;pointer-events:none;height:0px;width:0px;bottom:100%;right:42px;border-width: 6px; border-style: solid; margin: 0px -6px; border-color: transparent transparent white; " class=""'
  187. u.innerHTML = '<div style="border-top-color:rgb(219, 228, 236);border-width: 1px medium medium; border-style: solid none none; margin: 4px 13px; "></div>'
  188. k.innerHTML = '<div style="border-top-color:rgb(219, 228, 236);border-width: 1px medium medium; border-style: solid none none; margin: 4px 13px; "></div>'
  189. w.innerHTML ='Моя страница'
  190. n.innerHTML = 'Редактировать'
  191. setlnk.innerHTML ='Настройки'
  192. suplnk.innerHTML ='Помощь'
  193. suplnk.innerHTML ='Помощь'
  194. loglnk.innerHTML ='Выйти'
  195.  
  196.  
  197. if (namealt!=null){
  198.  
  199. s.insertBefore(q,s.firstChild)
  200. setlnk.insertAdjacentElement('beforeBegin', w);
  201. var home = document.querySelector('a#top_home_link')
  202. parentlnk.insertBefore(u,setlnk)
  203. parentlnk.insertBefore(k,loglnk)
  204. parentlnk.insertBefore(n,setlnk)
  205. parentlnk.insertBefore(k2,home)
  206.  
  207. for (b1 = 0; b1 < remove2.length; b1++) {
  208. remove2[b1].remove();
  209. }}
  210. //console.log('Фикс прошёл успешно')
  211. }
  212.  
  213. // Фикс в видео
  214. function check_vid(){
  215. var h2
  216. var myvd = document.querySelector('li#l_pr a.left_row')
  217. var h = myvd.href
  218. h2 = h.split('vk.com/')[1];
  219. //console.log(h2)
  220. if (!window.location.href.includes(h2)&&(!window.location.href.includes('/video/@'))){
  221. seacrh2();
  222. pop_vid();
  223.  
  224. }
  225. if (window.location.href.includes(h2)){
  226. my_vid();
  227. seacrh();
  228. }
  229. if (window.location.href.includes('/video?z=')&&(vd=0)){
  230. check_vid_ads();
  231. }
  232. if (window.location.href.includes('https://vk.com/video/@')&&!window.location.href.includes(h2)){
  233. seacrh3();
  234. }
  235. }
  236.  
  237. function seacrh(){
  238. // Установка старого поиска
  239. var search = document.querySelector('.ui_search_new.ui_search.ui_search_field_empty.video_search_input.VideoSearchInput.ui_search_custom.ui_search_with_custom_controls._wrap')
  240. if (search){
  241. search.classList= 'ui_search_new ui_search ui_search_field_empty video_search_input ui_search_btn_large _wrap'
  242.  
  243. // Передвижение поиска
  244. var parent = document.querySelector('div#video_main_block h2.page_block_h2')
  245. var child = document.querySelector('.ui_search_new.ui_search.ui_search_field_empty.video_search_input.ui_search_btn_large._wrap')
  246. parent.appendChild(child)
  247. }}
  248.  
  249. function seacrh3(){
  250. var search = document.querySelector('.ui_search_new.ui_search.ui_search_field_empty.video_search_input.VideoSearchInput.ui_search_custom.ui_search_with_custom_controls._wrap')
  251. var header = document.querySelector('div#video_block_header')
  252. if (search){
  253. search.classList= 'ui_search_new ui_search ui_search_field_empty video_search_input ui_search_btn_large _wrap'
  254. header.after(search)
  255. }
  256. }
  257.  
  258.  
  259. function my_vid(){
  260. var head = document.querySelectorAll('.page_block_header.clear_fix')
  261. if (head[1]){
  262. head[1].outerHTML = `<ul class="ui_tabs clear_fix ui_tabs_header ui_tabs_with_progress" onmouseover="uiTabs.tryInit(this)" id="video_main_tabs" data-inited="1">
  263. <li id="videocat_tab_all">
  264. <a href="#" class="ui_tab ui_tab_sel" onclick="document.querySelector('a.MenuList__item.MenuList__item--expandable').click();">
  265. Мои видео
  266. </a>
  267. </li><li id="videocat_tab_catalog">
  268. <a href="/video" class="ui_tab" onclick="return uiTabs.goTab(this, event, 1);">
  269. Видеокаталог
  270. </a>
  271. </li><li>
  272. <div class="ui_tab_plain ui_tabs_progress" role="link">
  273.  
  274.  
  275. </div>
  276. </li> <button style="margin-left: 0" class="flat_button">Добавить видео</button><button class="flat_button secondary" id="video_create_live_btn">Создать трансляцию</button> <button class="flat_button secondary" id="video_add_album_btn" onclick="return Video.createAlbum(event);" style="">Создать альбом</button>
  277. <div class="ui_tabs_slider _ui_tabs_slider" style="width: 83.6875px; margin-left: 14px;"></div>
  278. </ul>`
  279. var t = document.querySelector('button.flat_button[style="margin-left: 0"]')
  280. var t2 = document.querySelector('button#video_create_live_btn')
  281.  
  282. t.addEventListener("click", add, false);
  283. t2.addEventListener("click", add1, false);
  284. }}
  285.  
  286. function seacrh2(){
  287. // Установка старого поиска
  288. var search = document.querySelector('.ui_search_new.ui_search.ui_search_field_empty.video_search_input.VideoSearchInput.ui_search_custom.ui_search_with_custom_controls._wrap')
  289. if (search){
  290. search.classList= 'ui_search_new ui_search ui_search_field_empty video_search_input ui_search_btn_large _wrap'
  291.  
  292. // Передвижение поиска
  293. var parent = document.querySelector('.ui_gallery__arrow.ui_gallery__arrow_left')
  294. var child = document.querySelector('.ui_search_new.ui_search.ui_search_field_empty.video_search_input.ui_search_btn_large._wrap')
  295. parent.before(child)
  296. }}
  297.  
  298.  
  299. function check_vid_ads(){
  300. var main_vid = document.querySelector('.videoplayer_media video')
  301. var ads_vid = document.querySelector('video.videoplayer_ads_media_el')
  302. if (ads_vid){
  303. ads_vid.pause();
  304. main_vid.play();
  305. //console.log('text')
  306. vd=1
  307. }else{
  308. vd=0
  309. }
  310. }
  311.  
  312.  
  313. function pop_vid(){
  314. var head2 = document.querySelector('ul#video_main_tabs')
  315. var head = document.createElement('ul')
  316. head.classList='gg'
  317.  
  318. //console.log(head2)
  319.  
  320. var slider = document.querySelector('.ui_gallery.VideoTabsSlider.js-video-slider')
  321. if (slider){
  322. slider.classList='ui_gallery VideoTabsSlider'
  323. }
  324. var search = document.querySelector('.ui_search_new.ui_search.ui_search_field_empty.video_search_input.ui_search_btn_large._wrap')
  325. if (head2==null){
  326. if (search){
  327. search.before(head)
  328.  
  329. head2 = document.querySelector('ul.gg')
  330. head2.outerHTML=`<ul class="ui_tabs clear_fix ui_tabs_header ui_tabs_with_progress" onmouseover="uiTabs.tryInit(this)" id="video_main_tabs" data-inited="1">
  331. <li id="videocat_tab_all">
  332. <a href="#" class="ui_tab" onclick="document.querySelector('a.MenuList__item.MenuList__item--expandable').click();">
  333. Мои видео
  334. </a>
  335. </li><li id="videocat_tab_catalog">
  336. <a href="/video" class="ui_tab ui_tab_sel" onclick="return uiTabs.goTab(this, event, 1);">
  337. Видеокаталог
  338. </a>
  339. </li><li>
  340. <div class="ui_tab_plain ui_tabs_progress" role="link">
  341. </div>
  342. </li> <button style="margin-left: 0" class="flat_button" onclick="document.querySelectorAll('.VideoActions__item')[1].click();">Добавить видео</button><button class="flat_button secondary" id="video_create_live_btn" onclick="document.querySelector('.VideoActions__item.VideoActions__item--secondary').click();">Создать трансляцию</button> <button class="flat_button secondary" id="video_add_album_btn" onclick="return Video.createAlbum(event);" style="display: none;">Создать альбом</button>
  343. <div class="ui_tabs_slider _ui_tabs_slider" style="width: 103.906px; margin-left: 14px; transform: translateX(92px);"></div>
  344. </ul>`
  345. head2 = document.querySelector('ul#video_main_tabs')
  346. }}}
  347.  
  348.  
  349. function add(){
  350. var h = document.querySelector('.VideoActions__item[aria-label="Добавить видео"]')
  351. h.click();
  352. }
  353. function add1(){
  354. var h = document.querySelector('.VideoActions__item.VideoActions__item--secondary')
  355. h.click();
  356. }
  357.  
  358.  
  359.  
  360. var KPP
  361. KPP = {
  362. _list: [],
  363. _actions: [],
  364. _addedTag: function (observer, mutations, tag, callback, once) {
  365. for (var i = 0, l = mutations.length; i < l; i++) {
  366. for (var j = 0, m = mutations[i].addedNodes.length; j < m; j++) {
  367. if (mutations[i].addedNodes[j].tagName === tag) {
  368. callback();
  369. if (once) observer.disconnect();
  370. }
  371. }
  372. }
  373. },
  374. _police: new MutationObserver(function (mutations) {
  375. for (var i = 0, l = mutations.length; i < l; i++) {
  376. for (var j = 0, m = mutations[i].addedNodes.length; j < m; j++) {
  377. if (mutations[i].addedNodes[j].nodeType === 1) {
  378. for (var k = KPP._list.length; k--;) {
  379. if (mutations[i].addedNodes[j].matches(KPP._list[k])) { // Обрабатывает только существующие элементы до DOMContentLoaded
  380. if (!mutations[i].addedNodes[j].KPPPassed) {
  381. KPP._actions[k](mutations[i].addedNodes[j]);
  382. mutations[i].addedNodes[j].KPPPassed = true;
  383. }
  384. } else {
  385. var n = mutations[i].addedNodes[j].querySelectorAll(KPP._list[k]);
  386. for (var o = 0, p = n.length; o < p; o++) {
  387. if (!n[o].KPPPassed) {
  388. KPP._actions[k](n[o]);
  389. n[o].KPPPassed = true;
  390. }
  391. }
  392. }
  393. //if (n.length > 0) break
  394. }
  395. }
  396. }
  397. }
  398. }),
  399. head: function (callback) {
  400. if (!document.head) {
  401. var observer = new MutationObserver(function (mutations, observer) {
  402. KPP._addedTag(observer, mutations, 'HEAD', callback, true)
  403. });
  404. observer.observe(document.documentElement, {childList: true});
  405. } else callback();
  406. },
  407. body: function (callback) {
  408. if (!document.body) {
  409. var observer = new MutationObserver(function (mutations, observer) {
  410. KPP._addedTag(observer, mutations, 'BODY', callback, true)
  411. });
  412. observer.observe(document.documentElement, {childList: true});
  413. } else callback();
  414. },
  415. add: function (selector, callback) {
  416. var q = document.querySelectorAll(selector);
  417. if (q.length > 0) {
  418. for (var i = q.length; i--;) {
  419. callback(q[i]);
  420. }
  421. }
  422. KPP._list.push(selector);
  423. KPP._actions.push(callback);
  424. KPP._police.observe(document.documentElement, {childList: true, subtree: true})
  425. },
  426. remove: function (selector) {
  427. var s = KPP._list.indexOf(selector);
  428. if (s !== -1) {
  429. KPP._list.splice(s, 1);
  430. KPP._actions.splice(s, 1);
  431. if (KPP._list.length < 1)
  432. KPP._police.disconnect();
  433. return true
  434. }
  435. return false
  436. },
  437. stop: function (full) {
  438. KPP._police.disconnect();
  439. if (full) {
  440. KPP._list = [];
  441. KPP._actions = [];
  442. }
  443. }
  444. };