nonem / Appledaily Content Show

// ==UserScript==
// @name         Appledaily Content Show
// @namespace    gogo_acs
// @version      1.4
// @description  Appledaily Member Login Bypass
// @author       Mesak
// @match        https://*.appledaily.com/*
// @match        https://www.nextmag.com.tw/*
// @grant        none
// @run-at       document-start
// @license MIT
// ==/UserScript==

(function () {
  'use strict';
   function insertBefore( ele , child ){
       return ele.insertBefore( child , ele.firstChild ) ;
   }
   function insertAfter(ele, newEl)
   {
        let parentEl = ele.parentNode;
        if( parentEl.lastChild == ele)
        {
            parentEl.appendChild(newEl);
        }else
        {
            parentEl.insertBefore(newEl,ele.nextSibling);
        }
   }
   function reContentCreate(ele)
   {
       let newEle = ele.cloneNode(true)
       newEle.style.display = 'block';
       newEle.querySelectorAll('script').forEach(function(oScript) {
           oScript.parentNode.removeChild( oScript );
       })
       newEle.childNodes.forEach(function(oElement) {
           if( oElement.nodeName.length > 10 ){
               oElement.parentNode.removeChild( oElement );
           }
       });
       return newEle;
   }
   document.addEventListener("DOMNodeRemoved", function(e){
      if( e.target.classList )
      {
          //nextmag
          if(e.target.classList.contains('article-content') ){
              let rContent = reContentCreate(e.target);
              insertAfter( document.querySelector('.ndPaywall') , rContent );
              console.log( rContent );
              document.querySelector('.ndPaywall').parentNode.removeChild( document.querySelector('.ndPaywall') );
          }

          if( e.target.classList.contains('ndArticle_margin') ){
              let rContent = reContentCreate(e.target);
              rContent.classList.remove("ndArticle_margin");
              insertBefore( document.querySelector('.ndArticle_content') , rContent );
              document.querySelector('.ndPaywall').parentNode.removeChild( document.querySelector('.ndPaywall') );
          }

          if( e.target.classList.contains('mediabox') )
          {
              let rContent = reContentCreate(e.target);
              rContent.classList.remove("mediabox");
              insertBefore( e.target.parentNode ,rContent );
              console.log( 'return mediabox');
          }
          if( e.target.id == 'playerVideo' )
          {
              let rContent = reContentCreate(e.target);
              rContent.id = 'playerVideoCus';
              insertBefore( e.target.parentNode ,rContent );
              console.log( 'return playerVideo');
          }
          if( e.target.id == 'video_player' )
          {
              let rContent = reContentCreate(e.target);
              rContent.id = 'video_playerCus';
              insertBefore( e.target.parentNode ,rContent );
              console.log( 'return video_player');
          }
      }
   });
})();