Results 1 to 3 of 3
-
19th Aug 2012, 11:59 PM #1OPMember
Hiring a "Chrome Extension" Developer (Screen capture)
Hi,
OK, this is an edit to my original post.
I will try to explain what I want as simply as I can.
There are many "Chrome Extensions" that captures a part of the screen, but I will use this one for example.
Once installed, I will use the tool to capture a certain area.
And then click DONE.
Now where it shows the list of image sites that you can upload to (imgur / immio / minus), I want to add an option for my website. www.ultraimg.com
Before I go through the hassle of creating buttons and editting css and all that, I just want to get the "uploading script" correct first.
I have tried changing the original code for "imm.to", so instead of sending the image to that website, I want it to send to my website, but I can't get it to work.
This is the main part of the code:
I've highlighted the part which sends the image to imm.to in red. I think this is the part that needs editing?
Code:var bg = chrome.extension.getBackgroundPage(); var DEBUG_PICT_DOWN = false; var DEBUG_IMM_DOWN = false; var globalImageURL; var canvas; var canvastemp; var context; var contexttemp; var clickedTool; var canvasLeft; var ajaxObj; var aborted = false; var hoveringOverFontSize = false; if (!window.BlobBuilder && window.WebKitBlobBuilder) { window.BlobBuilder = window.WebKitBlobBuilder; } function writeText(str, context, x, y) { if (context.fillText) { context.fillText(str, x, y); } else if (context.strokeText) { context.strokeText(str, x, y); } } function watermarkImage() { if (canvas.width > 200) { setShadow(false); context.font = 'normal 10px sans-serif'; c.strokeStyle = c.fillStyle = "black"; writeText("Explain and Send Screenshots", context, 10, 15); writeText(bg.screenShotTab.url, context, 10, canvas.height-15); c.strokeStyle = c.fillStyle = drawingColor; } } function setShadow(flag, offset) { if (flag) { if (!offset) { offset = 5; } context.shadowOffsetX = contexttemp.shadowOffsetX = offset; context.shadowOffsetY = contexttemp.shadowOffsetY = offset; context.shadowBlur = contexttemp.shadowBlur = 4; context.shadowColor = contexttemp.shadowColor = "gray"; } else { context.shadowOffsetX = contexttemp.shadowOffsetX = 0; context.shadowOffsetY = contexttemp.shadowOffsetY = 0; context.shadowBlur = contexttemp.shadowBlur = 0; context.shadowColor = contexttemp.shadowColor = "none"; } } $(document).ready(function() { function postImage(callback) { aborted = false; $("#donate").hide(); $("#processing").dialog({ minHeight: 50, width: 600, position: [null, 120], modal: true, close: function(event, ui) { if (ajaxObj) { aborted = true; ajaxObj.abort(); } } }); setTimeout(function() { $("#hurried").slideDown(); }, 5000); $("#previewImage").attr("src", canvas.toDataURL()); setTimeout(function() { console.log("1: " + new Date()) var myThreadedEncoder = new JPEGEncoderThreaded("js/jpeg_encoder_threaded_worker.js"); console.log("2: " + new Date()) var imageData = context.getImageData(0, 0, canvas.width, canvas.height); console.log("3: " + new Date()) var myPrepardedImage = myThreadedEncoder.encode(imageData, 100, function(imageSrc) { console.log("4: " + new Date()) //$("#editedImage").attr("src", imageSrc); if (aborted) { return; } callback({ imageURL : imageSrc }); }, false); }, 500) console.log("5: " + new Date()) } function initTools() { if (lastToolUsed == "select") { c.tool.down(); } } function initFonts() { var fontSize; var fontSizePref = pref("fontSize", "normal"); $(".fontSize").removeClass("selected"); if (fontSizePref.match(/small/i)) { $("#fontSmall").addClass("selected"); fontSize = 12; } else if (fontSizePref.match(/normal/i)) { $("#fontNormal").addClass("selected"); fontSize = 18; } else { $("#fontLarge").addClass("selected"); fontSize = 30; } context.font = 'bold ' + fontSize + "px sans-serif"; $("#text").css("font", context.font); } var image = new Image(); image.src = bg.screenShotData; image.onload = function() { canvas = document.getElementById('canvas'); canvastemp = document.getElementById('canvastemp'); var rightMargin = 0; if (bg.grabMethod == "entirePage") { rightMargin = bg.SCROLLBAR_WIDTH; } canvas.width = canvastemp.width = image.width - rightMargin; canvas.height = canvastemp.height = image.height; context = canvas.getContext('2d'); contexttemp = canvastemp.getContext('2d'); context.drawImage(image, 0, 0); canvasLeft = $("canvas").offset().left; $("#canvastemp").css("left", canvasLeft ); // if image is small then lower the top of the image editing box to show a space between header and image if (canvas.width < 600) { //$("#canvas").before($("<br/><br/>")) $("#workspace").css("margin-top", "30px"); } initPaint() initFonts(); setShadow(true); } $("#toolbar li img").click(function() { setShadow(true); clickedTool = $(this); if (clickedTool.attr("src").indexOf("select") != -1) { setShadow(false); c.tool = new tool.select(); document.getElementById("canvas").className = "line"; } else if (clickedTool.attr("src").indexOf("ellipsis") != -1) { initTools(); c.tool = new tool.ellipse(); document.getElementById("canvas").className = "line"; } else if (clickedTool.attr("src").indexOf("blur") != -1) { setShadow(false); initTools(); c.tool = new tool.eraser(); document.getElementById("canvas").className = "line"; } else if (clickedTool.attr("src").indexOf("rectangle") != -1) { initTools(); c.tool = new tool.rectangle(); document.getElementById("canvas").className = "line"; } else if (clickedTool.attr("src").indexOf("drawFreehand") != -1) { initTools(); c.tool = new tool.pencil(); document.getElementById("canvas").className = "line"; } else if (clickedTool.attr("src").indexOf("line") != -1) { initTools(); c.tool = new tool.line(); document.getElementById("canvas").className = "line"; } else if (clickedTool.attr("src").indexOf("text") != -1) { console.log("text clicked"); $("#editingInstructions").slideUp("fast", function() { $("#textOptions").slideDown(); }); setShadow(true, 1) initTools(); c.tool = new tool.text(); document.getElementById("canvas").className = "text"; } else if (clickedTool.attr("src").indexOf("undo") != -1) { undo(); return; } else if (clickedTool.attr("src").indexOf("refresh") != -1) { window.location.reload(); return; } else { initTools(); c.tool = new tool.arrow(); document.getElementById("canvas").className = "line"; } if (!clickedTool.attr("src").match("text")) { $("#textOptions").fadeOut(); } $("#toolbar li img").each(function(i) { if (clickedTool.attr("src") == $(this).attr("src")) { var newSrc = $(this).attr("src").replace("Off", "On"); $(this).attr("src", newSrc); } else { var newSrc = $(this).attr("src").replace("On", "Off"); $(this).attr("src", newSrc); } }); }); $("#text").blur(function() { if (!hoveringOverFontSize) { console.log("text blur: " + hoveringOverFontSize) //context.font = 'bold 18px sans-serif'; context.textBaseline = 'top'; c.fillStyle = c.strokeStyle; var x = $(this).position().left - canvasLeft + 1; var y = $(this).position().top - 1; var lineHeight = 22; var lines = $(this).val().split("\n"); for (a=0; a<lines.length; a++) { writeText(lines[a], context, x, y); y += lineHeight; } $(this).hide(); document.getElementById("workspace").className = "text"; } }); function showOptions(response) { if (response == null || response.error) { //$(".displayForSharing").hide(); $("#editedImage").attr("src", canvas.toDataURL()); } if (response == null) { //$("#error").css("color", "brown").html("In privacy mode sharing links are disabled!<br>When pasting you might have to use: Edit > Paste Special > As Bitmap").show(); $("#error").css("color", "brown").html("Sharing links no longer supported for now, sorry!<br>When pasting you might have to use: Edit > Paste Special > As Bitmap").show(); } else if (response.error) { $("#error").html(response.error + ", sharing links will be disabled, please try again later!").show(); } else { //$("#error").css("color", "brown").html("Sharing links no longer supported for now, sorry!<br>When pasting you might have to use: Edit > Paste Special > As Bitmap").show(); //$(".displayForSharing").hide(); var image = document.getElementById("editedImage"); image.onload = function() { $("#bottomFooterMsg").css("margin-top", $("#editedImage").height() - 44); } $("#editedImage").attr("src", response.imageURL); //$("#imageURL").val(response.imageURL); //globalImageURL = response.imageURL; } $("#toolbar").hide(); $("#editor").hide(); $("#shareOptions").show(); var width = canvas.width; if (width < 600) { //$("#editedImageWrapper").css("width", width + 200); } $("#processing").dialog("destroy"); } $("#done").click(function() { initTools(); if (!pref("removeHeaderFooter")) { watermarkImage(); } if (pref("doNotHostOnline")) { showOptions(null, true); } else { // imm not working in chrome 6 hack here //showOptions(null); postImage(function(response) { showOptions(response); }); } }); $("#colorPicker").click(function() { $("#colorGrid").toggle(); $("#colorGrid").css("left", $("#colorPicker").offset().left + "px"); sendGA(['_trackEvent', "colorPicker", "click"]); }); $(".color").click(function() { var color = $(this).css("background-color"); setDrawingColor(color); $("#colorPicker").css("background-color", color); $("#text").css("color", color); $("#colorGrid").hide(); }); $("*[msg]").each(function() { $(this).text(chrome.i18n.getMessage( $(this).attr("msg") )); }); $("*[msgTitle]").each(function() { $(this).attr("title", chrome.i18n.getMessage( $(this).attr("msgTitle") )); }); $("*[msgSrc]").each(function() { $(this).attr("src", chrome.i18n.getMessage( $(this).attr("msgSrc") )); }); $("#shareLinks a").click(function(e) { if (!globalImageURL) { alert("You must upload it first by clicking the upload link above!"); return; } if ($(this).attr("id") == "fb") { facebookShare(globalImageURL, "Captured by 'Explain and Send Screenshots'"); } if ($(this).attr("id") == "twitter") { tweet(globalImageURL, "Captured by 'Explain and Send Screenshots'"); } if ($(this).attr("id") == "myspace") { location.href = "http://www.myspace.com/Modules/PostTo/Pages/?u=" + encodeURIComponent(globalImageURL); } if ($(this).attr("id") == "gmail") { var url = "https://mail.google.com/mail/?view=cm&tf=0&fs=1&su=screenshot&body=" + encodeURIComponent(globalImageURL + "\n\nCaptured by Explain and Send Screenshots - http://*******/oS7lxz"); window.open(url, 'sharer', 'toolbar=0,status=0,resizable=1,width=626,height=536'); //location.href = "https://mail.google.com/mail/?view=cm&tf=0&fs=1&body=" + encodeURIComponent(globalImageURL); } if ($(this).attr("id") == "hotmail") { location.href = "http://www.hotmail.msn.com/secure/start?action=compose&body=" + encodeURIComponent(globalImageURL); } $("#copyToClipboard").click( function() { $("#imageURL").select().focus(); document.execCommand('Copy'); $("#copyToClipboard").html(chrome.i18n.getMessage("readyForPasting")); }); }); $("#pixlr").click(function() { uploadImage("immio", function(params) { if (params.error) { $("#error").html(params.error + ", please try again later!").show(); } else { location.href = "http://www.pixlr.com/editor/?image=" + params.imageURL + "&title=Captured by 'Explain and Send Screenshots'"; } }); }); function sendMultipart(url, fileParams, dataParams, callback) { var BOUNDARY = "---------------------------1966284435497298061834782736"; var rn = "\r\n"; var data = new BlobBuilder() var append = function(dataParam) { data.append(dataParam) } /* var data = "", append = function(dataParam){ data += dataParam; } */ append("--" + BOUNDARY); for (var i in dataParams) { append(rn + "Content-Disposition: form-data; name=\"" + i + "\""); append(rn + rn + dataParams[i] + rn + "--" + BOUNDARY); } append(rn + "Content-Disposition: form-data; name=\"" + fileParams.name + "\""); append("; filename=\"" + fileParams.filename + "\"" + rn + "Content-type: " + fileParams.contentType); append(rn + rn); var bin = atob(canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "")); //file.data var arr = new Uint8Array(bin.length); for(var i = 0, l = bin.length; i < l; i++) { arr[i] = bin.charCodeAt(i); } append(arr.buffer) //append(bin) append(rn + "--" + BOUNDARY); append("--"); ajaxObj = $.ajax({ url: url, type: "POST", contentType: "multipart/form-data", timeout: 45000, processData: false, // Useful for not getting error when using blob in data data: data.getBlob(), // refer to processData flag just above beforeSend: function(request) { request.setRequestHeader("Content-type", "multipart/form-data; boundary=" + BOUNDARY); }, complete: function(request, textStatus) { callback({request:request, textStatus:textStatus}); } }); }; function uploadImage(website, callback) { try { /* if (true) { ajaxObj = $.ajax({ url: "http://www.imgplace.com/upload-pc.php", type: "POST", timeout: 45000, //data: "thefile0=" + encodeURIComponent(canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "")), data: canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, ""), complete: function(request, textStatus) { var status = getStatus(request, textStatus); alert(status) alert(request.responseText) alert(request.responseXML) alert(request.responseText.substring(2000)) alert(request.responseText.substring(3000)) alert(request.getAllResponseHeaders()); alert(request.getResponseHeader("location")); } }); } */ /* sendMultipart("http://post.imageshack.us/", {name:"fileupload", filename: "test.png", contentType:"image/png"}, {"uploadtype": "on", "refer":"http://imageshack.us/"}, function(params) { var request = params.request; var textStatus = params.textStatus; var status = getStatus(request, textStatus); alert(status); alert(request.responseText); console.log(request); }); return; */ if (website == "chemical") { ajaxObj = $.ajax({ url: "http://files.chemicalservers.com/api.php", type: "POST", timeout: 45000, data: "file=" + encodeURIComponent(canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "")), complete: function(request, textStatus) { var status = getStatus(request, textStatus); if (status == 200) { var code = request.responseText; $.ajax({ url: "http://files.chemicalservers.com/download.php?code=" + code + "&fn=screenshot.png", type: "GET", timeout: 45000, complete: function(request, textStatus) { status = getStatus(request, textStatus); if (status == 200) { try { var idx = request.responseText.indexOf("location="); var str = request.responseText.substring(idx, idx+500); var relativeUrl = str.split("'")[1]; var imageURL = "http://files.chemicalservers.com/" + relativeUrl; callback({imageURL: imageURL}); } catch (e) { console.error("Error parsing download page: " + e); location.href = this.url; } return; } else { callback({textStatus:textStatus, status:status}); } } }); //callback({imageURL: "http://files.chemicalservers.com/download.php?code=" + code + "&fn=screenshot.png"}); } else { callback({textStatus:textStatus, status:status}); } } }); } else if (website == "immio") { // imm.io ajaxObj = $.ajax({ url: "http://imm.io/?callback=true&name=screenshot", type: "POST", contentType: "multipart/form-data", timeout: 45000, data: 'image='+encodeURIComponent(canvas.toDataURL()), beforeSend: function(request) { request.setRequestHeader('Content-type','application/x-www-form-urlencoded'); }, complete: function(request, textStatus) { var status = getStatus(request, textStatus); if (status == 200) { var indirectURL = request.responseText; $.ajax({ url: indirectURL, type: "GET", timeout: 45000, complete: function(request, textStatus) { status = getStatus(request, textStatus); if (status == 200) { var body = findTag(request.responseText, "body"); // Find direct link var imageURL = $(body).find("img").attr("src"); // else find indirect link if (!imageURL) { imageURL = $(body).find("input").attr("value"); } if (imageURL) { if (imageURL.indexOf("http") == -1) { imageURL = "http://imm.io" + imageURL; } callback({imageURL:imageURL, deleteURL:indirectURL + "/delete"}); } else { // send them to imm.io's share page because couldn't find any link location.href = indirectURL; } return; } else { //callback({error:"Error: " + status + " - " + textStatus}); location.href = request.responseText; } } }); } else if (status == 413) { var host = parseURL(this.url).host; callback({textStatus:textStatus, error: "Sorry, the screenshot was too large for for " + host + " - try using a smaller screenshot or a different upload site"}); } else { callback({textStatus:textStatus, status:status}); } } }); } else if (website == "imgur") { ajaxObj = $.ajax({ url: "http://api.imgur.com/2/upload.json", type: "POST", timeout: 45000, data: "key=84010d2485980951155fb3b15b5972c8&image=" + encodeURIComponent(canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "")), complete: function(request, textStatus) { var status = getStatus(request, textStatus); if (status == 200) { try { var o = JSON.parse(request.responseText); console.log(o) callback({imageURL:o.upload.links.original, deleteURL:o.upload.links.delete_page}); } catch (e) { console.error("error: " + e); callback({textStatus:textStatus, error:"Error: " + e + " Please try again or try later"}); } } else { try { var o = JSON.parse(request.responseText); console.error("error: " + status + " - " + textStatus + " " + o.error.message); callback({textStatus:textStatus, error:o.error.message}); } catch (e) { console.error("error: " + status + " - " + textStatus); callback({textStatus:textStatus, status:status}); } } } }); } else if (website == "minus") { /* Minus.createGallery(function(gallery) { var bin = atob(canvas.toDataURL().replace(/^data:image\/(png|jpg);base64,/, "")); //file.data var arr = new Uint8Array(bin.length); for(var i = 0, l = bin.length; i < l; i++) { arr[i] = bin.charCodeAt(i); } //append(arr.buffer) alert("after bin: " + arr.buffer) Minus.uploadItem(gallery.editor_id, "test.png", "image/png", arr.buffer, function(file) { alert('file: ' + file.id) callback({imageURL:file.id}); } ); }); return; */ function newGallery(cb){ bg.minusGallery.obsolete = true; var xhr = new XMLHttpRequest(); xhr.open("GET", "http://min.us/api/CreateGallery", true); xhr.onload = function(){ var info = JSON.parse(xhr.responseText); info.time = +new Date; bg.minusGallery = info; console.log(info); cb(); } xhr.onerror = function(e){ //callback('error: min.us could not create gallery') alert("error: " + e); } xhr.send(); } function upload(){ bg.minusGallery.time = +new Date; sendMultipart("http://min.us/api/UploadItem?editor_id="+bg.minusGallery.editor_id+"&filename=test.png", {name:"file", filename: "test.png", contentType:"image/png"}, {}, function(params) { var request = params.request; var textStatus = params.textStatus; var status = getStatus(request, textStatus); if (status == 200) { var uploadInfo = JSON.parse(request.responseText); ajaxObj = $.ajax({ url: 'http://min.us/api/GetItems/m'+bg.minusGallery.reader_id, timeout: 5000, complete: function(request, textStatus) { var status = getStatus(request, textStatus); if (status == 200) { var j = JSON.parse(request.responseText).ITEMS_GALLERY var filename = ""; for(var i = 0; i < j.length; i++){ if(j[i].indexOf(uploadInfo.id) != -1){ filename = j[i]; i++; //increment by one as counter starts at one break; } } // minus link: 'http://min.us/m'+bg.minusGallery.reader_id+'#'+i callback({imageURL:filename}); } else { console.error("error: " + status + " - " + textStatus); callback({textStatus:textStatus, status:status}); } } }); } else { console.error("error: " + status + " - " + textStatus); callback({textStatus:textStatus, status:status}); } }); } if(bg.minusGallery.time && bg.minusGallery.time > (+new Date) - (1000 * 60 * 10)){ //keep uploading to the same gallery until 10 minutes of inactivity upload(); }else if(bg.minusGallery.obsolete){ //when somethings outdated theres a potential race condition (function(){ if(bg.minusGallery.obsolete){ setTimeout(arguments.callee, 100); }else{ upload() } })() }else{ newGallery(upload) } } } catch (e) { console.error("error: " + e); callback({error:"Error: " + e + ". Please try later or try another upload site!"}); } } $(".uploadWebsite").click(function() { var $uploadWebsite = $(this); $("#uploadProcessing").show(); $("#uploadWebsitesWrapper").slideUp("fast", function() { var website = $uploadWebsite.attr("site"); sendGA(['_trackEvent', "uploadWebsite", website]); uploadImage(website, function(params) { if (params.textStatus || params.error) { if (params.error) { alert(params.error) } else if (params.textStatus = "timeout") { alert("Host might be down, please try another one..."); } else { alert("Error " + params.textStatus + " with host, please try another one..."); } $("#uploadWebsitesWrapper").show(); $("#uploadProcessing").hide(); return false; } else { $("#uploadProcessing").html(chrome.i18n.getMessage("readyToShare")); $("#imageURL").val(params.imageURL); if (params.deleteURL) { $("#deleteURL").val(params.deleteURL); $("#deleteURLWrapper").show(); } globalImageURL = params.imageURL; $("#shareLinks").show(); $("#imageURL").click(); } }); return false; }); return false; }); $("#uploadWebsites li").click(function() { $(this).find(".uploadWebsite").click(); }); $("#imageURL, #deleteURL").click(function() { $(this).select(); }); if (pref("donationClicked")) { $("#donate").hide(); } if (pref("removeHeaderFooter")) { $("#topHeaderMsg, #bottomFooterMsg").hide(); $("#editedImage").css("float", "none"); } $("#topHeaderMsg, #bottomFooterMsg").click(function() { if (donationClicked("removeHeaderFooter")) { location.href = "options.html"; } }); $("#donate").click(function() { location.href = "donate.html?fromOptions=true"; }); $(".fontSize").click(function() { if (donationClicked("fontSize")) { console.log("fontsize"); localStorage["fontSize"] = $(this).attr("id"); initFonts(); } }).mouseenter(function() { hoveringOverFontSize = true; }).mouseleave(function() { hoveringOverFontSize = false; }); $("#createLink, #linkExample").click(function() { $("#createLinkWrapper").slideUp(); $("#shareWrapper").slideDown(); }); });
Can this be changed so that it uploads to my site!! UltraIMG.com ??
If so, how?? I've been looking through the code, but I can't figure it out.
Please if anyone can help that would be great!!
My website is based on the Chevereto script.
ThanksAshleyuk1984 Reviewed by Ashleyuk1984 on . Hiring a "Chrome Extension" Developer (Screen capture) Hi, OK, this is an edit to my original post. I will try to explain what I want as simply as I can. There are many "Chrome Extensions" that captures a part of the screen, but I will use this one for example. https://chrome.google.com/webstore/detail/mdddabjhelpilpnpgondfmehhcplpiinhttp://ultraimg.com/images/DhukC.png Once installed, I will use the tool to capture a certain area. Rating: 5
UltraIMG - Free Image Hosting
Want to ask me anything to do with UltraIMG?? Send me a PM.
Chances are that if you leave a message on the forum I might not see it. :)
-
20th Aug 2012, 11:28 PM #2Member
You can only take screenshots from websites within the browser, not from anywhere else - for obvious security reasons
-
21st Aug 2012, 12:44 AM #3OPMember
EDITED MY ORIGINAL POST.
UltraIMG - Free Image Hosting
Want to ask me anything to do with UltraIMG?? Send me a PM.
Chances are that if you leave a message on the forum I might not see it. :)
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
A True "Chrome" Supporter
By _Vick in forum General DiscussionReplies: 16Last Post: 19th Jan 2012, 08:20 AM -
How can I make my Back-up website "Immediately" to replace my "Original Site"??
By fuchen in forum Webmaster DiscussionReplies: 11Last Post: 13th Aug 2011, 04:14 PM -
[hiring] Need a "web hosting company" site set up.
By brainst0rm in forum Completed TransactionsReplies: 1Last Post: 23rd Sep 2010, 03:57 AM -
Hiring a Team or Looking for a partner for "Making Money Forum".
By brainst0rm in forum Completed TransactionsReplies: 8Last Post: 22nd Aug 2010, 09:44 AM -
Lawsuit ramps up pressure over Microsoft's "black screen" anti-piracy move
By DJ Norix in forum News & Current EventsReplies: 0Last Post: 29th Oct 2008, 02:51 PM
themaCreator - create posts from...
Version 3.23 released. Open older version (or...