JZersche

Facebook JSInject Show Archive Buttons

Nov 22nd, 2020
634
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     FB: Post Screenshot
  3. // @match    https://www.facebook.com/*
  4. // @match    https://*.facebook.com/*
  5. // @match    http://www.facebook.com/*
  6. // @match    http://*.facebook.com/*
  7. // @run-at   document-start
  8. // @grant    GM_addStyle
  9. // @author   JZersche
  10. // @require  https://greasyfork.org/scripts/12228/code/setMutationHandler.js
  11. // @version 1.05
  12. // @namespace https://greasyfork.org/users/95175
  13. // @description Remove Status after Screenshot Button is clicked.
  14. // ==/UserScript==
  15.  
  16. if(!location.href.includes('SEARCH_BOX')) {
  17.     setMutationHandler({
  18.         target: document,
  19.         selector: '._5pcb._4b0l._2q8l',
  20.         handler: nodes => nodes.forEach(node => {
  21.             // var dwg_PostID = node.childNodes[0].childNodes[0].childNodes[1].childNodes[0].childNodes[1].nextSibling.childNodes[0].childNodes[0].childNodes[1].childNodes[1].childNodes[0].childNodes[0].childNodes[1].childNodes[1].childNodes[0].childNodes[0].childNodes[0].href.match(/\d+/);
  22.             // var ____PostID = JSON.stringify(dwg_PostID).replace('\["','').replace(']','').replace('\"','');
  23.             var ArchiveRecord = sessionStorage.getItem('A');
  24.             ArchiveRecord = JSON.stringify(ArchiveRecord);
  25.             setTimeout( function() {
  26.                 //var dwg_PostID = JSON.stringify(node.innerHTML.match(/posts\/\d+/));
  27.                 //var ____PostID = dwg_PostID;
  28.                 console.log(node.id.substring(38, 54));
  29.                 console.log(ArchiveRecord.includes(node.id.substring(38, 54)));
  30.                 console.log(ArchiveRecord);
  31.                 if( ArchiveRecord.includes(node.id.substring(38, 54)) ) { node.setAttribute('style','background:yellow!important;'); };
  32.             }, 1000);
  33.             //____PostID;
  34.             //var post = node;
  35.             //var P = node.parentNode;
  36.             //////////////var ArchiveRecord = localStorage.getItem('A').match(/\d+/g);
  37.             //////////////ArchiveRecord = JSON.stringify(ArchiveRecord);
  38.             //alert(ArchiveRecord);alert(____PostID);
  39.             //            if(ArchiveRecord.match(____PostID)) {
  40.             //P.removeChild(post);
  41.             //alert(ArchiveRecord+' - '+____PostID);
  42.             //              node.setAttribute('style','background:yellow!important;');
  43.             //           };
  44.         })
  45.     })
  46.  
  47.     setMutationHandler({
  48.         target: document.querySelector('._558b'),
  49.         selector: '._54nc[title="Save screenshot"]',
  50.         handler: nodes => nodes.forEach(node => {
  51.             node.addEventListener('click', function (event) {
  52.                 var post = document.getElementsByClassName('_5pcb')[0];
  53.                 var P = post.parentNode;
  54.  
  55.                 P.removeChild(post);
  56.             })
  57.         })
  58.     })
  59.  
  60.  
  61.     var i = 0;
  62.     var ii = 0;
  63.     var not_Anonymous = 0;
  64.  
  65.     setMutationHandler({
  66.         target: document.querySelector('._3576'),
  67.         selector: '._5pcp',
  68.         processExisting: true,
  69.         handler: node => {
  70.             //alert(node[0].innerText);
  71.             if (location.href.match(/facebook\.com\/\w+\S\w+/) && !location.href.match(/\S+\/\S+\/posts\/\d+/)) {
  72.                 /* Delay Script */
  73.                 setTimeout(function () {
  74.                     //alert(document.querySelectorAll('._1dwg._1w_m._q7o').length);
  75.                     try{
  76.                         if(!node[0].parentNode.parentNode.outerHTML.match(/Archive/) && node[0].closest('div').parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes[0].title.length > 1) {
  77.                             node[0].insertAdjacentHTML('afterend', '<input type="button" class="ArchiveButton" name="arch" value=""/>'); //alert('a');
  78.                             node[0].nextSibling.setAttribute('style','  background-image: linear-gradient(to left, indigo, white, white, white);-webkit-background-clip: text;-webkit-text-fill-color: transparent;');
  79.                         }
  80.                         if(!node[1].parentNode.parentNode.outerHTML.match(/Archive/) && node[1].parentNode.className.match(/_6a _5u5j _6b/)) {
  81.                             node[1].insertAdjacentHTML('afterend', '<input type="button" class="ArchiveButton" name="arch" value=""/>');//alert('b');
  82.                             node[1].nextSibling.setAttribute('style','background-image: linear-gradient(to left, indigo, white, white, white);-webkit-background-clip: text;-webkit-text-fill-color: transparent;');
  83.                         }
  84.                         if(!node[2].parentNode.parentNode.outerHTML.match(/Archive/) && node[2].parentNode.className.match(/_6a _5u5j _6b/)) {
  85.                             node[2].insertAdjacentHTML('afterend', '<input type="button" class="ArchiveButton" name="arch" value=""/>');//alert('c');
  86.                             node[2].nextSibling.setAttribute('style','background-image: linear-gradient(to left, indigo, white, white, white);-webkit-background-clip: text;-webkit-text-fill-color: transparent;');
  87.                         }
  88.                         if(!node[3].parentNode.parentNode.outerHTML.match(/Archive/) && node[3].parentNode.className.match(/_6a _5u5j _6b/)) {
  89.                             node[3].insertAdjacentHTML('afterend', '<input type="button" class="ArchiveButton" name="arch" value=""/>');//alert('d');
  90.                             node[3].nextSibling.setAttribute('style','background-image: linear-gradient(to left, indigo, white, white, white);-webkit-background-clip: text;-webkit-text-fill-color: transparent;');
  91.                         }
  92.                         if(!node[4].parentNode.parentNode.outerHTML.match(/Archive/) && node[4].parentNode.className.match(/_6a _5u5j _6b/)) {
  93.                             node[4].insertAdjacentHTML('afterend', '<input type="button" class="ArchiveButton" name="arch" value=""/>');//alert('e');
  94.                             node[4].nextSibling.setAttribute('style','background-image: linear-gradient(to left, indigo, white, white, white);-webkit-background-clip: text;-webkit-text-fill-color: transparent;');
  95.                         }
  96.                     } catch(Error) {}
  97.                 }, 100);
  98.  
  99.             }
  100.         }
  101.     });
  102.  
  103.     let iiii = 0; let intP = 0;
  104.     setMutationHandler({
  105.         target: document.querySelector('.u_1zif-yanm'),
  106.         selector: '.ArchiveButton',
  107.         processExisting: true,
  108.         handler: nodes => nodes.forEach(node => {
  109.             if (document.readyState === 'complete' && !location.href.match(/facebook\.com\/\w+\S\w+\//)) {
  110.                 iiii++; let PostID = node.parentNode.childNodes[1].childNodes[0].childNodes[0].childNodes[0].href.match(/\d{9,16}/);
  111.                 node.setAttribute("value",'['+iiii+'] Archive:'+PostID);
  112.             }
  113.  
  114.         })
  115.     });
  116.  
  117.  
  118. }
  119.  
  120.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×