알쓸전컴(알아두면 쓸모있는 전자 컴퓨터)

chrome Web engine 에서 에딧봇 사용 설정 본문

cafe24 쇼핑몰

chrome Web engine 에서 에딧봇 사용 설정

백곳 2018. 8. 15. 00:33

chrome Web engine 에서 에딧봇 사용 설정


Qt 나 cefshap 에서 chrome 을 사용 하지만


에딧봇에서 자꾸 크롬을 인식을 하지 못하는 현상이 있습니다.



소스를 보면


해당 open(oParam)에서 Iframe 을 추가 시킵니다.

그리고  나서



크롬을 구분 한뒤에



여기서 구분을 해줍니다.


그래서


저는 첫번째 소스 부분을 보고서


this.EDIBOT.open = function (option) {
        var link = "/cstore-admin/edibot/editor/main?"+Date.now();
        this.runtime = option;
        var closehandler = option.close || function () {
            };
        this.runtime.close = function () {
            closehandler();
            if (container && container.parentNode) {
                container.parentNode.removeChild(container);
            }
            document.body.style.overflow = "auto";
        };
        var container = document.createElement('div');
        container.id = "EDIBOT_CONTAINER";
        container.dataset.version = this.version;
        var iframe = document.createElement('iframe');
        iframe.setAttribute("src", link);
        container.appendChild(iframe);
        document.body.style.overflow = "hidden";
        document.body.appendChild(container);
    console.log($('#EDIBOT_CONTAINER > iframe').get(0).contentWindow);
    $('#EDIBOT_CONTAINER > iframe').get(0).contentWindow.chrome = {test : 'test'}
    $('#EDIBOT_CONTAINER > iframe').get(0).contentWindow.chrome.webstore = true
    }


console 에서 입력 하여


open 함수를 바꿔 줍니다.


그리고 나서 실행 하면 실행이 됩니다.

      QString str = QString("this.EDIBOT.open = function (option) { \n"
                              "var link = \"/cstore-admin/edibot/editor/main?\"+Date.now()\; \n"
                              "this.runtime = option; \n"
                              "var closehandler = option.close || function () { \n"
                               "};\n"
                              "this.runtime.close = function () { \n"
                                  "closehandler(); \n"
                                  "if (container && container.parentNode) { \n"
                                      "container.parentNode.removeChild(container); \n"
                                  "} \n"
                                  "document.body.style.overflow = \"auto\"; \n"
                              "}; \n"
                              "var container = document.createElement(\'div\'); \n"
                              "container.id = \"EDIBOT_CONTAINER\"; \n"
                              "container.dataset.version = this.version; \n"
                              "var iframe = document.createElement(\'iframe\'); \n"
                              "iframe.setAttribute(\"src\", link); \n"
                              "container.appendChild(iframe); \n"
                              "document.body.style.overflow = \"hidden\"; \n"
                              "document.body.appendChild(container); \n"
                          "console.log($('#EDIBOT_CONTAINER > iframe').get(0).contentWindow); \n"
                          "$(\'#EDIBOT_CONTAINER > iframe\').get(0).contentWindow.chrome = {test : \'test\'} \n"
                          "$(\'#EDIBOT_CONTAINER > iframe\').get(0).contentWindow.chrome.webstore = true \n"
                          "}");
        qDebug()<<str;
        page()->runJavaScript(str);


Qt Webengine 에서는 위와 같이 사용해서 해결 했습니다.




Comments