From a8ede08103aa0373ae378b238b6de61591e342ce Mon Sep 17 00:00:00 2001 From: Oguzhan Ergin Date: Tue, 23 Dec 2014 03:25:05 +0200 Subject: [PATCH] initial release --- chrome-addon/src/content.js | 99 ++++++++++++++++++++++++++ chrome-addon/src/icons/128x128.png | Bin 0 -> 2181 bytes chrome-addon/src/icons/16x16.png | Bin 0 -> 1000 bytes chrome-addon/src/icons/48x48.png | Bin 0 -> 1786 bytes chrome-addon/src/manifest.json | 15 ++++ ff-addon/coming soon | 0 userscript/OfficeOnlineViewer.user.js | 99 ++++++++++++++++++++++++++ 7 files changed, 213 insertions(+) create mode 100644 chrome-addon/src/content.js create mode 100644 chrome-addon/src/icons/128x128.png create mode 100644 chrome-addon/src/icons/16x16.png create mode 100644 chrome-addon/src/icons/48x48.png create mode 100644 chrome-addon/src/manifest.json create mode 100644 ff-addon/coming soon create mode 100644 userscript/OfficeOnlineViewer.user.js diff --git a/chrome-addon/src/content.js b/chrome-addon/src/content.js new file mode 100644 index 0000000..2408638 --- /dev/null +++ b/chrome-addon/src/content.js @@ -0,0 +1,99 @@ +// ==UserScript== +// @name Office Online Viewer +// @description View office documents in your browser with Microsoft Office Online +// @namespace ogzergin +// @version 0.1 +// @include * +// @exclude http*://view.officeapps.live.com/* +// @exclude http*://docs.google.com/* +// @exclude http*://mail.google.com/* +// @exclude http*://viewer.zoho.com/* +// @exclude http*://office.live.com/* +// ==/UserScript== + +var pageLinks=document.links; +var fileTypes=["doc","docx","xls","xlsx","ppt","pps","pptx"]; + +//https://view.officeapps.live.com/op/view.aspx?src= +var strOfficeHost ="view.officeapps.live.com"; +var strViewOfficeUrl = "https://" + strOfficeHost + "/op/view.aspx?src="; + +parseLinks(); + +addDebouncedEventListener(document, 'DOMNodeInserted', function(evt) { + parseLinks(); +}, 1000); + +function endsWith(str, suffix) { // check if string has suffix + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} + +function stripQueryString(str) { + return str.protocol + '//' + str.hostname + str.pathname; +} + +function parseLinks(){ + + for(var i=0;i http://i.imgur.com/Wce14X6.png + //powerpoint => http://i.imgur.com/iQn5mKp.png + // excel => http://i.imgur.com/xPTt5d6.png +function addOfficeLink(link){ + var officeLink = document.createElement('a'); + officeLink.href = strViewOfficeUrl + encodeURI(stripQueryString(link)); + officeLink.isParsed=true; + officeLink.target="_blank"; + + var ico = document.createElement("img"); + + if(endsWith(officeLink.href, ".doc")||endsWith(officeLink.href, ".docx")) + ico.src = "http://i.imgur.com/Wce14X6.png"; + else if(endsWith(officeLink.href, ".xls")|| endsWith(officeLink.href, ".xlsx")) + ico.src = "http://i.imgur.com/xPTt5d6.png"; + else + ico.src = "http://i.imgur.com/iQn5mKp.png"; + + + ico.style.marginLeft = "5px"; + officeLink.appendChild(ico); + link.parentNode.insertBefore(officeLink, link.nextSibling); + +} + +function addDebouncedEventListener(obj, eventType, listener, delay) { + var timer; + + obj.addEventListener(eventType, function(evt) { + if (timer) { + window.clearTimeout(timer); + } + timer = window.setTimeout(function() { + timer = null; + listener.call(obj, evt); + }, delay); + }, false); +} diff --git a/chrome-addon/src/icons/128x128.png b/chrome-addon/src/icons/128x128.png new file mode 100644 index 0000000000000000000000000000000000000000..01262c3577e364cfed84c8bf2aacd05b7d83edd7 GIT binary patch literal 2181 zcmd^>`8U-67suabjAa;vY%>#O8)X?we2ffZNy;Fi8bdQNLSqS&LYZbP6++o6%TSSR zs2JPWs}G?hT9mbXA|FfBu^WBI_k2Eo#pj&Yz4zRE&+FbFUgta?uN$t;4lt++6aWC2 z;}JVIL8R}Pn25l4VadIMAQa)|U<0sUBW4AO@HreF2LMmfB(}&9K`tJ4wSqxFqb{>pI$0MQjkJKTv&KJ)kR z)Ds>`iKX*SrH`z#2ca-MeqF6wonC?`^!kXBf=otwZu$%;3nJmvM7oxdTSJ;;K(=+! zdov&sa)ur8N+x#V#m99-)H@jI^s^vw!{^qz$H%4Lq|YwF@&_$eEscL!_S~^>TI}P$ zHaGY_7PDX{*@gc1xHe)CW%2hX6h2Oln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nH z7h}a0OJSdF)Z+MR_+yqJBt5=d(Kl(ZAX3pu^{OX{3Ike;!u)amg!j1@GnU~x9FWA0 z={5WGJO(Ji+(2_yn+1*Stt0GE0nErtgixk2(HH*7!6|Qnsa9Z3zv@^t(6^h9hgqR6 zjvP(CM|= zDn~c=yh;9{bNACk`}E0lU2$>ISoz9LbjH!>p#4Dl81IEwwk9k#l$K##Vw!Wb^i%EBF26q1LZ4kqvVrt-hJl zSW}1>T2a${hEMCJWn$X)Tm#he{?j}wpDLFnDdQ`8?b?>-dXPm4Zx(k9$Lo;ON`jjCxcy{*|Dl`*rxqs$5w z(To?UBxO!|zD1YL{-6HCRExD+s0rowEG&Mz;_eNtLi zn)|;U8r7{1EzSMCyRk#hpj0KbV|L~jQEM*VKat46N-M^M+Odcxedx~>6IAK*Dyd!_ zNc!|xl%#T~vnZ9B->Ql6u5ivMM0smBH~nh!<$Cq-mn7ZweFj5+eug_24;S<&?6pztOkpaIu{msx!2!%hM$;=?U6%R_E4QsO>zn<6=Es zC>+slU|x=*@C-Vv5gbBzx~r;qsCvW43+dN@B#x5JE}gl{!9=3o^jvdZrM42c+E0zG z`JQPryo=P)^e?0-w%o1>XQz7yOLod%yb|+}TvFz>je3bF7p)3VeAO>2u~HczmbQ2F zAzn%BGSbs$PdZi68)pM{;oM)3rrP^b$syEmTv$Rlmw+MGz*yJ7P}ji3)6f8CfW;Xa z=weN9SgfHBPVIjT7bxWDh}8dYutR0v;2LDUU+|zrP*Xw@!a-a}bSzabHk_(#tcTSz UD*mV1ojU`Z?cE4%w!zu|0>^Uvl>h($ literal 0 HcmV?d00001 diff --git a/chrome-addon/src/manifest.json b/chrome-addon/src/manifest.json new file mode 100644 index 0000000..602eb63 --- /dev/null +++ b/chrome-addon/src/manifest.json @@ -0,0 +1,15 @@ +{ + "name": "Office Online Viewer", + "version": "0.1", + "manifest_version": 2, + "description" : "View office documents in your browser with Microsoft Office Online", + "icons": { "16": "icons/16x16.png", "48": "icons/48x48.png", "128": "icons/128x128.png" }, + + "content_scripts": [ + { + "matches": ["http://*/*", "https://*/*"], + "exclude_matches": ["http://view.officeapps.live.com/*", "https://view.officeapps.live.com/*", "http://office.live.com/*", "https://office.live.com/*", "http://docs.google.com/*", "https://docs.google.com/*", "http://mail.google.com/*", "https://mail.google.com/*", "http://viewer.zoho.com/*", "https://viewer.zoho.com/*"], + "js": ["content.js"] + } + ] +} \ No newline at end of file diff --git a/ff-addon/coming soon b/ff-addon/coming soon new file mode 100644 index 0000000..e69de29 diff --git a/userscript/OfficeOnlineViewer.user.js b/userscript/OfficeOnlineViewer.user.js new file mode 100644 index 0000000..2408638 --- /dev/null +++ b/userscript/OfficeOnlineViewer.user.js @@ -0,0 +1,99 @@ +// ==UserScript== +// @name Office Online Viewer +// @description View office documents in your browser with Microsoft Office Online +// @namespace ogzergin +// @version 0.1 +// @include * +// @exclude http*://view.officeapps.live.com/* +// @exclude http*://docs.google.com/* +// @exclude http*://mail.google.com/* +// @exclude http*://viewer.zoho.com/* +// @exclude http*://office.live.com/* +// ==/UserScript== + +var pageLinks=document.links; +var fileTypes=["doc","docx","xls","xlsx","ppt","pps","pptx"]; + +//https://view.officeapps.live.com/op/view.aspx?src= +var strOfficeHost ="view.officeapps.live.com"; +var strViewOfficeUrl = "https://" + strOfficeHost + "/op/view.aspx?src="; + +parseLinks(); + +addDebouncedEventListener(document, 'DOMNodeInserted', function(evt) { + parseLinks(); +}, 1000); + +function endsWith(str, suffix) { // check if string has suffix + return str.indexOf(suffix, str.length - suffix.length) !== -1; +} + +function stripQueryString(str) { + return str.protocol + '//' + str.hostname + str.pathname; +} + +function parseLinks(){ + + for(var i=0;i http://i.imgur.com/Wce14X6.png + //powerpoint => http://i.imgur.com/iQn5mKp.png + // excel => http://i.imgur.com/xPTt5d6.png +function addOfficeLink(link){ + var officeLink = document.createElement('a'); + officeLink.href = strViewOfficeUrl + encodeURI(stripQueryString(link)); + officeLink.isParsed=true; + officeLink.target="_blank"; + + var ico = document.createElement("img"); + + if(endsWith(officeLink.href, ".doc")||endsWith(officeLink.href, ".docx")) + ico.src = "http://i.imgur.com/Wce14X6.png"; + else if(endsWith(officeLink.href, ".xls")|| endsWith(officeLink.href, ".xlsx")) + ico.src = "http://i.imgur.com/xPTt5d6.png"; + else + ico.src = "http://i.imgur.com/iQn5mKp.png"; + + + ico.style.marginLeft = "5px"; + officeLink.appendChild(ico); + link.parentNode.insertBefore(officeLink, link.nextSibling); + +} + +function addDebouncedEventListener(obj, eventType, listener, delay) { + var timer; + + obj.addEventListener(eventType, function(evt) { + if (timer) { + window.clearTimeout(timer); + } + timer = window.setTimeout(function() { + timer = null; + listener.call(obj, evt); + }, delay); + }, false); +}