RauchenwaldC

eToro Content Filter - Page Observer

May 9th, 2021 (edited)
420
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (!observer.isConnected()) {
  2.     setTimeout(() => {
  3.         let postsContainer = document.querySelectorAll('ui-layout.ng-isolate-scope');
  4.         if (typeof postsContainer[0] != 'undefined') {
  5.             observer.observe(postsContainer[0], {childList: true, subtree: true});
  6.         }
  7.     }, 0);
  8. }
  9.  
  10. --- CHANGE TO ---
  11.  
  12. // check if pageObserver is connected or is currently trying to connect
  13. var bConnecting = false;
  14. if (!observer.isConnected() && !bConnecting) {
  15.     // check if current page is feed
  16.     if (window.location.pathname.indexOf('/feed') > -1) {
  17.         // check if main feed exists on page
  18.         var feedWrapper = document.getElementsByClassName('main-feed-wrapper');
  19.         if (typeof feedWrapper[0] != 'undefined') {
  20.             console.log('Connecting pageObserver');
  21.             bConnecting = true;
  22.             let postContainer = document.querySelectorAll('ui-layout.ng-isolate-scope');
  23.             if (typeof postContainer[0] != 'undefined') {
  24.                 observer.observe(postContainer[0], { childList: true, subtree: true });
  25.             } else {
  26.                 bConnecting = false;
  27.             }
  28.         }
  29.     }
  30. }
RAW Paste Data