Facebook (Insert View Post Button)

Inserts a View Post button when browsing photos on Facebook — e.g. Navigates away from the standard theater view

目前為 2021-06-24 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Facebook (Insert View Post Button)
  3. // @match https://www.facebook.com/*
  4. // @match http://www.facebook.com/*
  5. // @icon https://www.google.com/s2/favicons?domain=facebook.com
  6. // @run-at document-start
  7. // @grant GM_addStyle
  8. // @author JZersche (Free Release)
  9. // @version 1.00
  10. // @namespace https://greasyfork.org/users/95175
  11. // @description Inserts a View Post button when browsing photos on Facebook — e.g. Navigates away from the standard theater view
  12. // ==/UserScript==
  13.  
  14. setTimeout(function() {
  15.  
  16. if(window.location.href.match(/(facebook\.com\/photo\/\?fbid\=\d+\&set\=a\.\d+|facebook\.com\/\S+\/photos\/a\.\d+\/\d+)/)) {
  17.  
  18. try{
  19.  
  20. let Facebook_username = document.getElementsByClassName('oajrlxb2 g5ia77u1 qu0x051f esr5mh6w e9989ue4 r7d6kgcz rq0escxv nhd2j8a9 nc684nl6 p7hjln8o kvgmc6g5 cxmmr5t8 oygrvhab hcukyx3x jb3vyjys rz4wbd8a qt6c0cv9 a8nywdso i1ao9s8h esuyzwwr f1sip0of lzcic4wl oo9gr5id gpro0wi8 lrazzd5p')[0].href.match(/com\/\S+\?/)[0].match(/\/\S+/)[0].replace('/','').replace('?','');
  21.  
  22. try{let postID = window.location.href.match(/\?fbid\=\d+/)[0].match(/\d+/)[0];}catch(e){}
  23. try{let postID2 = window.location.href.match(/facebook\.com\S+\/photos\/a\.\d+\/\d+/)[0].match(/\d+/g)[1];
  24.  
  25. if(Facebook_username == 'profile.php') {
  26. Facebook_username = postID2};
  27. console.log(Facebook_username);
  28. }catch(e){}
  29.  
  30. try{let setID = window.location.href.match(/(&set\=a\.\d+)/)[0].match(/\d+/)[0];}catch(e){}
  31. try{let setID2 = window.location.href.match(/(a\.\d+)/)[0];}catch(e){}
  32.  
  33. try{let EditButton = document.getElementsByClassName('rq0escxv l9j0dhe7 du4w35lb j83agx80 pfnyh3mw taijpn5t bp9cbjyn owycx6da btwxx1t3 kt9q3ron ak7q8e6j isp2s0ed ri5dt5u2 rt8b4zig n8ej3o3l agehan2d sk4xxmp2 d1544ag0 tw6a2znq tdjehn4e tv7at329')[0];
  34.  
  35. if(EditButton) {
  36. EditButton.insertAdjacentHTML('afterend','<div class="'+EditButton.className+' viewpost" style="font-family: inherit; font-weight:600; font-size:14px; color:#fff!important"><a href="#">View Post</a></div>');
  37. document.getElementsByClassName('viewpost')[0];
  38. }
  39. }catch(e){}
  40.  
  41. try{
  42. let ViewPostButton = document.getElementsByClassName('a8nywdso j7796vcc rz4wbd8a l29c1vbm')[0];
  43. if(ViewPostButton) {
  44.  
  45.  
  46. try{
  47. if(window.location.href.match(/facebook\.com\/\D+/)[0]){
  48. ViewPostButton.insertAdjacentHTML('afterend','<div class="viewpost" style="font-family: inherit; font-weight:600; font-size:14px; color:#fff!important"><a href="http://www.facebook.com/'+window.location.href.match(/facebook\.com\/\S+\/photos/)[0].replace('facebook.com/','').replace('/photos','')+'/posts/'+window.location.href.match(/facebook\.com\S+\/photos\/a\.\d+\/\d+/)[0].match(/\d+/g)[1]+'">View Post</a></div>');
  49. console.log('a');
  50. }
  51. }catch(e){}
  52.  
  53. try{
  54. if(window.location.href.match(/facebook\.com\/\d+/)[0]) {
  55. ViewPostButton.insertAdjacentHTML('afterend','<div class="viewpost" style="font-family: inherit; font-weight:600; font-size:14px; color:#fff!important"><a href="http://www.facebook.com/'+window.location.href.match(/facebook\.com\/\S+\/photos/)[0].replace('facebook.com/','').replace('/photos','')+'/posts/'+window.location.href.match(/facebook\.com\S+\/photos\/a\.\d+\/\d+/)[0].match(/\d+/g)[2]+'">View Post</a></div>');
  56. console.log('b');
  57. }
  58. }catch(e){}
  59.  
  60. }
  61.  
  62.  
  63. }catch(e){}
  64.  
  65. }
  66.  
  67. catch(e){}
  68.  
  69.  
  70. }
  71.  
  72. },5000);