JavaScript - How To View And Parse Source From An Extension?
Hi,
I'm creating an extension on Firefox that wishes to parse the source of a page that the user is currently viewing for specific information. I've gotten as far as creating a simple extension with a button and when I click on it, it will show the url of the page I am currently viewing through: content.location.href All the examples I've seen so far concerning viewing the source forces you to either use the 'view-source:' convention or the 'xmlhttprequest' method. But these examples seems to be meant to be called within a web page and not an extension. When I cut and paste with these examples, I only get the source for the actual chrome portion of Firefox. I've tried modifying some of the examples to include 'content.document....etc' to reference what's being displayed in the browser, but it doesn't seem to work. Can anyone provide sample or reference code so I can extract the page source of my current window from an extension? Thanks! Similar Tutorialsrecently i noticed that all of my embedded JavaScript code and external style sheets are being shown IN "view source." this happens in all browsers ( IE, FF, Chrome, and Safari [windows]) ... oddly enough it only happens when viewing on my vista or win2k3 machines. is this something added to these OS's or the result of an installed program? has anyone seen this before? What is the code to stop people from viewing your source. Such as this site: http://bad-behavior.com (View The Source of That Site) I've searched the forums, and all I got was a bunch of "nothing can protect your source" I don't care about all of that. I want the code because: 1. Most people don't know how to view a source after it has been blocked 2. I think it's cool How do I hide my javascript from html page (from view source on right click)?
Hi , I made a table that retrieves some Data from the Database also I did some calculations for this data using Javascript and It works fine , but I can't see the calculated values in the source code . That's the Problem , cause I can't print it or export it without these values. and the source code doesnt show it... so , what can I do , to view the generated values from JS in the source code ?? Thanks , I'm afraid this is a task related to my job and I need ur Help Urgently I'm using IE 6 only as a web browser and the Javascript Calculations are functions and Classes in a seperated file and I linked it to the Report page ... I have created and opened a new window using Javascript and written to it with the document.write Command. When I click "View" and then "Page Source" (Firefox) to view the source of it, however, it displays a blank page. How can I get the source of a window I created? Thank You Charles Hi - I'm working in ASP.Net 2.0. My page has a GridView control, which is populated by a SQLDataSource. The GridView has one Button control per row. The button has a client-side javascript function (ShowDelete) attached to its OnClientClick event on DataBinding of the GridView. This event fires some javascript. The javascript does 3 things: - It changes the text of the button from "Hide" to "Create" - It changes the background color of the button from red to green - It assigns a new onClientClick event to the button: "ShowAvailable" The text and the color of the button change with no problem. After I change the OnClientClick event, I send an alert with the button's OnClientClick event and it reports it to be "ShowAvailable". However, when I click on the button, it doesn't fire ShowAvailable, it fires the original onClientClick event (ShowDelete). Also, when I do View Source, it shows the button's text, color and OnClientClick event as their original settings, i.e., "Hidden", "Red" and "ShowDelete", even though I'm looking at a green button that says "Create." What's going on here? Here's the code I use to attach the OnClientClick event on DataBinding of the GridView: Code: foreach (GridViewRow row in this.gvLocation.Rows) { if (row.RowType == DataControlRowType.DataRow || row.RowType == DataControlRowType.EmptyDataRow) { int rowindex = row.RowIndex + 1; //to exclude the header which is counted as a row when we get to javascript btnAction.OnClientClick = "ShowDelete(" + rowindex.ToString() + "); return false"; } } Here's the javascript for ShowDelete: Code: function ShowDelete(rowindex) { var locationgridID = '<%= gvLocation.ClientID %>'; locationgrid = document.getElementById(locationgridID); if (locationgrid != null) { action_cell = locationgrid.rows[rowindex].cells[3]; for (k = 0; k < action_cell.childNodes.length; k++) { if (typeof(action_cell.childNodes[k].id) == 'string') { action_cell.childNodes[k].value = "Create"; action_cell.childNodes[k].style.backgroundColor = "Green"; action_cell.childNodes[k].onclientclick = "ShowAvailable(" + rowindex + "); return false"; alert(action_cell.childNodes[k].onclientclick); // reports the OnClientClick event is ShowAvailable } } } } Any thoughts are greatly appreciated! Very new to Javascript (been a HTML/CSS guy for a while, but never really got into more than tinkering with other other people's Javascript coding), but I came across a situation I can't find canned coding for, and trying to create it from bits and pieces I Googled has led me to a dead-end. In summary, I have a website that I frequently visit (FWIW, Firefox 3.x is my browser of choice) with many image sources referring to URLs that end with "-thumbnail.jpg". However, for better image quality, I am trying to use Greasemonkey to replace all instances of "-thumbnail.jpg" in the source of images on this site with "-bigthumbnail.jpg". The closest I could think of was to somehow use getElementsByTagName and innerHTML.replace, but realized that innerHTML does not do HTML, only content. Below is as far as I tried to get on my own, I appreciate any assistance from the folks here to help a JS novice like myself, thanks! Code: (function() { var as,ae; as = document.getElementsByTagName("img"); for (var i = 0; i < as.length; i++) { ae = as[i]; ae.innerHTML = ae.innerHTML.replace(/-thumbnail/gi, "-bigthumbnail"); } })(); I have a piece of code for adding categories to a shopping site, which was working fine but now doesn't submit after I made changes to try to validate the type image chosen for that category. I'll post the original and then changed code, anyone think they can see why it's not running? Code: function checkCategoryForm() { with (window.document.frmCategory) { if (isEmpty(catName, 'Enter category name')) { return; } else if (isEmpty(catDescription, 'Enter category description')) { return; } else { submit(); } } } Code: function getFileExtension(filename) { var ext = /^.+\.([^.]+)$/.exec(filename); return ext == null ? "" : ext[1]; } function checkCategoryForm() { with (window.document.frmCategory) { if (isEmpty(catName, 'Enter category name')) { return; } else if (isEmpty(catDescription, 'Enter category description')) { return; } else { if (getFileExtension(fileImage) = '.jpg' || '.jpeg' || '.png' || '.gif' ){ submit(); } else { alert("Enter this image format is not allowed, only .jpg, .png or .gif"); return; } } } } Thanks! First off I apologize If this is in the wrong section of this forum. So I got this concept that I think Is pretty cool. I dont know If there's anything like It out there, If there is, let me know. This is the concept: You click the icon and down pops a map in which there's a circle (like this: imgur: the simple image sharer) You can resize the circle and move it around. Underneath the map there's a box where you can type your search. Let's say you search for "puppies" in Brooklyn, New York The idea is that It'll scan all the coordinates inside the circle and search for photos in google images containing those coordinates in the GPS info (EXIF).This can be useful If you for example wants to search for photos taken in your city, or even in your neighborhood. I can see many uses for this. The thing is, I don't know any programming languages so I can't do this myself. I don't even know where to start. I'm looking for a kind soul to help me with this, I don't have any money so I'm not looking to pay anyone to do this for me. I just want some help getting started, or if someone would be kind enough to do It for free. (Though that Is very unlikely.) Thanks in advance! Sorry for my bad english, it is not my native language. Reply With Quote 01-30-2015, 04:24 PM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Hope springs eternal in the human breast. – Alexander Pope, An Essay on Man You might as well say that you want to write a novel in French, but do not know anything about that language. Hello. I have used the Firefox extension Linky for a very long time, it is one of my most used extensions bar none. However, one of the most attractive features of it broke somewhere in the updating from Firefox 3-4, as far as i know. I didn't find out about it until recently, due to never bothering to update past Firefox 3 until just a little while ago. industrial clay This feature was the 'Select already visited links' option, which also works in reverse, letting you unselect all links to pages you've already visited. (Or rather, have listed in your browser history) Now, i am a complete noob when it comes to JavaScript, and i have very little knowledge about this type of programming, so i have no chance to fix this myself. This, is the reason i came here. I hope someone will be able to take a quick look at this code, and maybe tell me how to fix it, or make a workaround, or something. I really want to get it working again. I am almost certain that the problem lies in this section of the code: Code: LinkySelect.prototype.checkVisited = function() { var gGlobalHistory = opener.Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory); var cbox = this.getChecked(document.getElementById("cvbox")); var selectlinks = document.getElementById("selectlinks"); var last = selectlinks.getRowCount(); for (var i = 0; i < last; i++) { var tmp = selectlinks.getItemAtIndex(i); if (gGlobalHistory.isVisited(tmp.getAttribute("value"))) { tmp.setAttribute("checked", this.setChecked(cbox)); } } this.updateInfo(); } Also, the Error Console reports this; Code: Error: opener.Components.classes['@mozilla.org/browser/global-history;1'] is undefined Source File: chrome://linky/content/select-links.js Line: 28 I hope that will tell someone something. I almost feels like it tells me something, but it's been years and years since i last tried to study this type of programming. Any help with this is appreciated. Thanks in advance for your time. I want to download text file generated in a textarea here my download.php file code structure goes : <?php if(empty($_POST['filename']) || empty($_POST['content'])){ exit; } $filename = preg_replace('/[^a-z0-9\-\_\.]/i','',$_POST['filename']); header("Cache-Control: "); header("Content-type: text/plain"); header('Content-Disposition: attachment; filename="'.$filename.'"'); echo $_POST['content']; ?> and the javascript used (function($){ $.generateFile = function(options){ options = options || {}; if(!options.script || !options.filename || !options.content){ throw new Error("Please enter all the required config options!"); } var iframe = $('<iframe>',{ width:1, height:1, frameborder:0, css:{ display:'none' } }).appendTo('body'); and the script.js $(document).ready(function(){ $('#download').click(function(e){ $.generateFile({ filename : 'export.txt', content : $('textarea').val(), script : 'download.php' }); e.preventDefault(); }); by these assets i created a web page consisting a TEXTAREA , by entering some text on the textarea and clicking on the download button , a text files is generated and downloaded on the user's system, I packed the source code as a CRX file to use it as a CHROME extension, but while using the extension,the files are'nt generated, while the webpage works absolutely fine !!! Hello. I have used the Firefox extension Linky for a very long time, it is one of my most used extensions bar none. However, one of the most attractive features of it broke somewhere in the updating from Firefox 3-4, as far as i know. I didn't find out about it until recently, due to never bothering to update past Firefox 3 until just a little while ago. This feature was the 'Select already visited links' option, which also works in reverse, letting you unselect all links to pages you've already visited. (Or rather, have listed in your browser history) Now, i am a complete noob when it comes to JavaScript, and i have very little knowledge about this type of programming, so i have no chance to fix this myself. This, is the reason i came here. I hope someone will be able to take a quick look at this code, and maybe tell me how to fix it, or make a workaround, or something. I really want to get it working again. I am almost certain that the problem lies in this section of the code: Code: LinkySelect.prototype.checkVisited = function() { var gGlobalHistory = opener.Components.classes["@mozilla.org/browser/global-history;1"].getService(Components.interfaces.nsIGlobalHistory); var cbox = this.getChecked(document.getElementById("cvbox")); var selectlinks = document.getElementById("selectlinks"); var last = selectlinks.getRowCount(); for (var i = 0; i < last; i++) { var tmp = selectlinks.getItemAtIndex(i); if (gGlobalHistory.isVisited(tmp.getAttribute("value"))) { tmp.setAttribute("checked", this.setChecked(cbox)); } } this.updateInfo(); } Also, the Error Console reports this; Code: Error: opener.Components.classes['@mozilla.org/browser/global-history;1'] is undefined Source File: chrome://linky/content/select-links.js Line: 28 I hope that will tell someone something. I almost feels like it tells me something, but it's been years and years since i last tried to study this type of programming. Any help with this is appreciated. Thanks in advance for your time. The mounds of RegExp data will take me days to sift through can someone help me create a regular expression to find a file extension? (all characters after a period) I have already gotten this far: .+\. to find everything before and including the period; and I was hoping to integrate the caret to say everything but .+\. But I just can't get it to work... Note: I will be writing a file to the server with JScript ASP. The file name will be passed to the script that writes the file, and I want to make sure that in addition to removing any possible code from the line being written, that I also prevent an executable file from being created. I will be searching for certain extensions and returning if anything else is found. Hi All, I have written a chrome extension which will redirect to all hrefs for a given source urls in current tab.. But i don't know why all of a sudden it stops executing after reaching some page. I am attaching my code as attachment. Can any one help me out. Thanks in advance. Hi, I am kinda new to java scripting and here is what i am trying to do. I have a folder "A" with 10 files, all with .txt extensions in it. I want a java script to open all the 10 files in the folder "A" and change the extensions to .js and save it in a folder "B". Can some one help. Thanks a lot in advance. |