Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Document Read
- // @namespace bogus
- // @include https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/
- // @version 1
- // @include https://docs.google.com/*
- // @include http://www.hemingwayapp.com/
- // @grant GM_openInTab
- // @grant GM_setValue
- // @grant GM_getValue
- // @grant GM_deleteValue
- // ==/UserScript==
- function beginsWith (a, b) {
- return a.substring(0,b.length) == b;
- }
- var tb = document.getElementById("docs-primary-toolbars");
- if (beginsWith (document.location.href, "https://docs.google.com/") && tb) {
- var nb = document.createElement("input");
- nb.type="button"
- nb.value="Check em"
- function getTexts(node){
- var text = "";
- if(node.nodeType === 3){
- text+=node.nodeValue+"\n";
- }
- else if(node.nodeType === 1) {
- var children = node.childNodes;
- for(var i = 0; i < children.length; ++i) {
- text += getTexts(children[i]);
- }
- }
- return text;
- }
- function checkem() {
- tt = document.getElementsByClassName("kix-appview-editor")[0];
- var texts = getTexts(tt);
- GM_setValue("hemingway-text", texts);
- GM_openInTab("http://www.hemingwayapp.com");
- }
- nb.onclick=checkem;
- tb.appendChild (nb);
- } else if (beginsWith(location.href, "http://www.hemingwayapp.com")) {
- var texts = GM_getValue ("hemingway-text");
- if (texts !== undefined) {
- var editor = document.getElementById("editor");
- editor.value=texts;
- GM_deleteValue ("hemingway-text");
- var event = document.createEvent("KeyboardEvent");
- event.initKeyEvent("keyup",true,true,null,false,false,false,false,0,0);
- editor.dispatchEvent(event);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement