[Web] Browser Developer Tools 技巧

Intro

本篇將以 Chrome 瀏覽器為主,介紹 Developer Tools 的實作技巧


Window.open() 新視窗監測

現行要監測某個 button click 會開啟轉導去哪,在前端框架下從 JS code 很難找出目的,若又是 window.open 效果則無法持續透過 developer tool 監測 Network 歷程

比較簡單暴力的做法是在該 web page 的 console 覆寫 window.open() 看要 console.log() 出來還是改成 redirect 以便監測 network

// Show the target URL
window.open = function(url, target, features) {
    console.log(url);
};

// Change to redirect
window.open = function(url, target, features) {
    window.location.href = url;
};

Leave a Reply

Your email address will not be published. Required fields are marked *