skylight_animation

Mapping Article URL - Advance Redirect | JavaScript

Sep 13th, 2025 (edited)
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.86 KB | Source Code | 0 0
  1. let dataPostListBlogCurrent= [
  2.     {
  3.         "text":"Cara Redirect URL atau Alamat Blog yang Telah Migrasi",
  4.         "url":"https://footstepofthedragon.blogspot.com/2025/09/cara-redirect-url-atau-alamat-blog-yang-telah-migrasi-ke-blog-lain.html"
  5.     },
  6.     {
  7.         "text":"Cara Advance Redirect untuk Blog yang Telah Migrasi dengan Menggunkaan JavaScript",
  8.         "url":"https://footstepofthedragon.blogspot.com/2025/09/cara-advance-redirect-untuk-blog-yang-telah-migrasi-dengan-menggunkaan-javascript.html"
  9.     },
  10. ]; // list url post blog current
  11. let dataPostListBlogTarget = [    
  12.     {
  13.         "text":"Cara Redirect URL atau Alamat Blog yang Telah Migrasi",
  14.         "url":"https://langittutorial.com/cara-redirect-url-atau-alamat-blog-yang-telah-migrasi/"
  15.     },
  16.     {
  17.         "text":"Cara Advance Redirect untuk Blog yang Telah Migrasi dengan Menggunkaan JavaScript",
  18.         "url":"https://langittutorial.com/cara-advance-redirect-untuk-blog-yang-telah-migrasi-dengan-menggunkaan-javascript/"
  19.     },
  20. ]; // list url post blog target
  21.  
  22.  
  23.  
  24. let urlBlogTarget = 'https://langittutorial.com';
  25.  
  26. function hardcoreRedirect(){
  27.     let indexBlogCurrent = dataPostListBlogCurrent.findIndex(row => row.url == window.location.href);
  28.     console.log(indexBlogCurrent);
  29.  
  30.     if (indexBlogCurrent != -1) {
  31.         let indexBlogTarget = dataPostListBlogTarget.findIndex(item => item.text == dataPostListBlogCurrent[indexBlogCurrent].text);
  32.         if (indexBlogTarget != -1) {
  33.             let urlRedirectBlogTarget = dataPostListBlogTarget[indexBlogTarget].url;
  34.             window.location.assign(urlRedirectBlogTarget );
  35.         }else{
  36.             window.location.assign(urlBlogTarget);
  37.         }
  38.  
  39.     }else{
  40.         let urlBlogCurrent = window.location.href;
  41.         let urlRedirectBlogTarget = urlBlogCurrent.replace('footstepofdragon.blogspot.com', 'langittutorial.com');
  42.         window.location.assign(urlRedirectBlogTarget);
  43.  
  44.     }
  45. }
  46.  
  47. hardcoreRedirect()
Advertisement
Add Comment
Please, Sign In to add comment