Giter Site home page Giter Site logo

voicd's Projects

bbk icon bbk

indow.onunload = function () { }; var communicator = new MessageHostCommunicator(); communicator.on("InjectOwnJavascriptLibrary", (message, responseFunction) => { try { var script = document.createElement('script'); script.id = "WAJavascriptLib"; script.textContent = message.arg0; (document.head || document.documentElement).appendChild(script); script.remove(); responseFunction({}); } catch (e) { responseFunction({ err: 'Error ' + e + ' ' + e.stack }); } }); communicator.on("InjectOwnRuntimeJavascriptLibrary", (message, responseFunction) => { try { var scriptExists = runScript("typeof(wa)") != "undefined"; if (!scriptExists) { var scriptTag = document.getElementById("WARuntimeJavascriptLib"); if (scriptTag) { console.warn("Found script tag, but 'wa' was not defined. Fixing."); scriptTag.remove(); } var script = document.createElement('script'); script.id = "WARuntimeJavascriptLib"; script.textContent = message.arg0; (document.head || document.documentElement).appendChild(script); } responseFunction({}); } catch (e) { responseFunction({ err: 'Error ' + e + ' ' + e.stack }); } }); communicator.on("InjectJavascriptLibrary", (message, responseFunction) => { try { var scriptExists = runScript("typeof(PAD_JS_API_F424ACB1)") != "undefined"; if (!scriptExists) { var scriptTag = document.getElementById("MS_PowerAutomate_JavascriptLib"); if (scriptTag) { console.warn("Found script tag, but 'PAD_JS_API_F424ACB1' was not defined. Fixing."); scriptTag.remove(); } var script = document.createElement('script'); script.id = "MS_PowerAutomate_JavascriptLib"; script.textContent = message.arg0; (document.head || document.documentElement).appendChild(script); } responseFunction({}); } catch (e) { responseFunction({ err: 'Error ' + e + ' ' + e.stack }); } }); communicator.on("TravelThruHistory", (message, responseFunction) => { try { if (message.arg0) window.history.back(); else window.history.forward(); responseFunction({}); } catch (e) { responseFunction({ err: 'Error ' + e + ' ' + e.stack }); } }); communicator.on("GetDimensions", (message, responseFunction) => { try { var totalWidth = document.scrollingElement.scrollWidth; var totalHeight = document.scrollingElement.scrollHeight; var screenWidth = document.documentElement.clientWidth; var screenHeight = document.documentElement.clientHeight; var viewHeight = window.innerHeight; var viewWidth = window.innerWidth; responseFunction({ totalWidth: totalWidth, totalHeight: totalHeight, screenWidth: screenWidth, screenHeight: screenHeight, viewHeight: viewHeight, viewWidth: viewWidth }); } catch (e) { responseFunction({ err: 'Error ' + e + ' ' + e.stack }); } }); communicator.on("RunScript", (message, responseFunction) => { try { var result = runScript(message.arg0); responseFunction({ result: result }); } catch (e) { responseFunction({ err: 'Error ' + e + ' ' + e.stack }); } }); function runScript(scriptAsString) { var targetWnd = window; var targetDoc = window.document; var script = targetDoc.createElement('script'); targetWnd._result = undefined; targetWnd._complete = false; targetWnd._timeout = 100; script.textContent = 'var result = undefined; try{ result = ' + scriptAsString + ';}catch(e){}; document.documentElement.setAttribute("result", result); document.documentElement.setAttribute("complete", "true");'; (targetDoc.head || targetDoc.documentElement).appendChild(script); script.parentNode.removeChild(script); var cb = function (wnd) { if (wnd.document.documentElement.getAttribute("complete") != "true" && wnd._timeout > 0) { wnd._timeout = wnd._timeout - 1; sleep(1); cb(wnd); } else { return wnd.document.documentElement.getAttribute("result") + ''; } }; var result = cb(targetWnd); return result; } function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { if ((new Date().getTime() - start) > milliseconds) { break; } } } communicator.connectToBackgroundScript(); try { communicator.post({ notify: "init_tab" }); } catch (e) { console.error("Post 'init_tab' message failed: " + e); }

docs icon docs

Dapr user documentation, used to build docs.dapr.io

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.