N
N
Nadim Zakirov2019-10-28 20:28:20
JavaScript
Nadim Zakirov, 2019-10-28 20:28:20

How to mask window.parent inside iframe using google chrome extension?

I am creating a VKontakte bot in the form of a browser plugin. For the convenience of control, I want to run the bot inside the frame, for which I specifically provided for the removal of the X-Frame-Options header in background.js:

chrome.webRequest.onHeadersReceived.addListener(

    function(info) { 
  
    var headers = info.responseHeaders; // Получаем массив отсылаемых заголовков
    
    // Обходим массив полученных заголовков:
    
    for (var i=headers.length-1; i>=0; --i) {
      
      var header = headers[i].name.toLowerCase(); // Считываем название того или иного заголовка
      
      // При наличии совпадений, удаляем заголовок нахрен:
      
      if (header == 'x-frame-options' || header == 'frame-options') { 
        headers.splice(i, 1);
      }
      
    }
    
    return {responseHeaders: headers}; // Вовращаем почищенный массив заголовков назад
    
    },
  
    { urls: [ '<all_urls>' ], types: [ 'sub_frame' ] },
  
    ['blocking', 'responseHeaders']
  
);

However, this was not enough, since VKontakte also uses a manual check for the fact that the page is loading in the frame. Here's a piece of code that simply deletes the page if it's a frame
5db724bf3a16f974459174.png
: Ideally, I would like to know, is it possible to completely disguise the frame under the main window window.top with the help of an extension? I would appreciate advice from more experienced colleagues.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question