Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm trying to "hack" a web app by customizing the login page.
I've succefully been able to change an <img>, but I can't seem to use some js.
Whenever I try a simple alert, it shows up on the source code but won't show up on the page.
I wonder if there's any way they blocked js or if I'm missing something on why my alert won't show up.
Below : screenshot of the img tag i've successfully changed and the js I failed to execute from the firefox dev tools.
Please let me know if you're missing some informations.
EDIT : I think I've gave you all the wrong idea :)
I'm not hacking anything. I have the source code of a huge web app.
Now what I'm trying to do is to customize some part of a page. I edited the source code adding an alert (that should show up and that won't).
Here is a part of my code :
<img id="Img_site" src="/images/custom/Img_site.png" style="margin-left:-40px;"/>
<script type="text/javascript">alert("test js")</script>
If you're trying to "hack" a web app that allows users to enter custom code. There is a good change that the developer of that web app put measures in place so strip any scripting. For example i have an application where users can enter custom markup but i have the below code on the front end to strip any script tags and any code in between them before they get submitted to the server. Then on the server I do the same thing to make sure that no script can be passed to the interface effecting users.
var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
while (SCRIPT_REGEX.test(html_code)) {
html_code = html_code.replace(SCRIPT_REGEX, "");
}
You have to notice that the content is already loaded when you append the script. So it won't excute. If you want inyect javascript code to the web you must use the developer tool.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
Improve this question
we are currently trying to read out maximum order quantity, since there is no option in any Amazon API, so we decided to scrape it in some way.
Keepa has some kind of option which is similar to that we want to achieve, but there is no scalable API available. (Keepa devs told us, there wont be any feature in the near future).
Here is an example:
Amazon has unlimited stock, means you can add 999 to cart and most likely even more
There is no add-to-cart "href" but the whole "buybox" is inside of a tag with an form:
Here is the whole form-tag of the BuyBox
Is there someway without rendering JavaScript to perform such kind of Request to Amazon to simulate a click on the add to cart button?
Thank you guys in advance!
In queries like these, be specific with
URL- you are trying to scrape.
mention the element you are trying to extract.
Share a piece of code, you are facing trouble with.
However, if you are trying to simulate the clicking a button on this website or any other browser like behaviour while scraping. Then, going with the browser-automation libraries with headless capabilities like Puppeteer, Playwright and Selenium are the best options. These libraries automatically renders the script tags. And, you can easily simulate the user-like behaviour like clicking a button in Puppeteer, Clicking the button in Playwright, and Clicking the button in Selenium.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 4 years ago.
Improve this question
A friend of mine programmed a website, using a tool from "1und1". The problem is, that, while you use this tool to easy create a website, you do not have any direct access to the code.
Now he did something stupid. He created a function, that relocates you, based on the language of you browser. This function however always relocates the user, no matter what language your browser has and this website never stops loading. Ones it is finished, it loads again.
My first intention was, to use the noscript-addon for Chrome, however the tool to edit this part also uses Javascript... So if i use noscript, this infinite reloading-problem is fixed temporary, but i cannot fix the problem once and for all!
Is there any way of only deactivating a certain script-part of the head-tag and not all of them?
Thank you all.
edit:
This is the Script in question:
//<![CDATA[
// The language of the browser as an orientation for the language of
// the user
var userLang = navigator.language || navigator.userLanguage;
// The current adress of the user
var adress = document.location.href;
if(adress == thisSite && userLang.match("de")) {
// german
window.location.href = '/deutsch/start/';
} else {
// fallback (english)
window.location.href = '/english/home/';
}
//]]>
Now, after trying a whole night, for everyone, who has a similar problem, this is how i fixed this.
You HAVE to call 1und1 or use there live-chat for this. They take some time to fix it, because the person, you are speaking to, also has no access to the code. They then give it to the development team, wich is fixing it.
However, if you want to prevent any problem like that, i can just recommend you, to not use this tool! This tool gives you all things you don't want and even in the expert section they want to "improve" your code, by correcting it, wich led to my "infinit-recursion-problem".
If you are wondering, he entered the following:
else if(adress == thisSite) {
// fallback (english)
window.location.href = '/english/home/';
}
but it deleted the if-clause, because it said, it was unnecessary and he didn't even recognized it, until it was too late.
Therefor i recommend you: "Do not use this kind of tools, if you have any other way to do this (like Wordpress or Joomla or even a friend, who can barely code)".
Open chromes developer tool. CTRL + SHIFT + I
go to the Elements tab
Find the peice of code you want to remove, right click it, select "Edit as html", remove/edit what you want to remove/edit, click somewhere else and it should affect the page accordingly.
You could go to the F12 menu and look under the elements tab. This houses all the current html/scripts/styling etc of the web page. Look for the script in question and just delete it, however, this is only a temporary local fix while on the page.
Hope that helps!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
For starters, I don't have much knowledge of JavaScript but I think I know enough to get the job done, I just need some pointers.
I'm trying to create an extension that will grab the profile_id from the current Facebook page that is open, and then put that in a URL and display the new page, e.g., https://www.facebook.com/search/profileid/photos-of
Unfortunately I can't seem to find any good documentation of how to do so. Displaying the new page shouldn't be an issue, but I don't know enough about JavaScript to pull the ID from a page. All the searching I've done tells me I should be using the Facebook Graph API, but I don't know where to get it or how to use it. Can anyone give me any tips or point me in the right direction, preferably to some tutorial that doesn't assume I've been using JavaScript and the Graph API for the past few years.
You don't have to use Graph API. Just open any page source in devtools (F12) and find (Ctrl-F) where profile ID is, then extract it from the most easy to process spot:
<meta property="al:android:url" content="fb://page/123456789012345">
Can be extracted in a content script with this code:
document.querySelector('meta[property="al:android:url"]').content
Your extension should have an event page that declares a listener for the browser toolbar button:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(
tab.id,
{code: "document.querySelector('meta[property=\"al:android:url\"]').content"},
function(results) {
var profileID = results[0].split('/')[3];
chrome.tabs.create({
url: 'https://www.facebook.com/search/' + profileID + '/photos-of',
active: true
});
}
);
});
Your manifest.json file should have at least "activeTab" permission.
There are lots of things to improve in the above code that's just a starting point.
Examine official sample extensions code to see various techniques in action.
Consult the documentation and API reference.
Always use the debugger before asking (tutorial, how to debug background/event pages)!
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I'm new at programming. I've done the HTML, CSS, website build and JAVASCRIPT courses on Codecademy. I've done some of the Eloquent Javascript and got a little lost in the sauce around chapter 5. I saw someone advise on here to take the JavascriptIsSexy route which I've been doing. I downloaded Notepad++ and have started going through "Beginning Javascript" book that is used in that "study guide". My problem is I cannot get anything, and I mean anything to run in a browser. IE, Firefox or Chrome. Even the simplest of things produce no output. The page loads either blank, or shows the first line of HTML and no more. Any blocks, functions and the like never run. White page. 1 or no lines. I've looked around for anyone having similar issues and haven't found it. Which makes me pretty sure I'm the problem here. I'd offer samples of code, but anything you can write in 60 would suffice as a good example. I am saving the files in a designated folder with the correct file types (.html or .js), closing all tags, etc.
Not exactly sure how to continue. I can't keep "practicing" if i cant get anything to run. I've tried using the RUN button in Notepad++ and selecting a browser. I've also tried opening a browser, choosing OPEN and selecting one of the files. I've even directly copied and pasted code right out of the book and tried to run it that way to make sure it isn't just a bug on my part. Same result.
I also tried writing and playing with codes in the "console" of IE and Chrome, but I can't get either of them to respond as I have no idea how to use them.
If this is a really dumb question or I haven't given you enough info to try and help me out, I apologize. I would appreciate any help you guys could throw out there.
Thanks.
First of all, you guys are awesome. I thought I'd be waiting for a couple days for some help. Seriously, that's cool. Here's a bit of code, one of the first examples the book has you run in a browser.
<html>
<body bgColor = "WHITE">
<p>Paragraph 1</p>
<script type="text/javascript">
alert("First Script Block");
</script7>
<p>Paragraph 2</p>
<script type="text/javascript">
document.bgColor ="RED";
alert("Second Script Block");
</script7>
<p>Paragraph 3</p>
</body>
</html>
Like I said. Very simple... I get nothing. Thanks again for the quick responses. You guys rock.
Open a new file in Notepad++ and add:
<!DOCTYPE HTML>
<html>
<body>
<script>
alert('This Should be a Popup Alert')
</script>
</body>
</html>
Save as test.html, make sure to save as "All Files".
Right click on the file, and open with any browser and should run in the browser just fine. Now just adapt the javascript you want to play with.
Not a dumb question at all. This is one of the most common things to try and get used to when you're starting out. So I'll ask you a question because this is the most common thing that newcomers forget - did you load all you files in to your index.html (or whatever your html file is name) file? If you're not sure, go to your website or page, and view source. Do a search for '.css'. If you can't find anything, you haven't loaded any stylesheets. Next do a search for 'script'. If you can't find that, you didn't include any javascript files. Is your site live? You need to FTP to it and upload the files to the server also. Here's a resource for importing your stylesheets and scripts into the DOM. http://webcomponents.org/articles/introduction-to-html-imports/ If you need help with FTP, let me know, I'd be glad to help, as I wish someone would have helped me when I was starting out.
If you are using console.log() to produce output, you won't see it in the browser's window that normally displays HTML. You need to look at the console. On Chrome it can be reached via the menu at View > Developer > Developer Tools.
Can you paste a code snippet in one of your index.html pages, you should try to learn and use xammp.
Install xammp
Once installed click the button "Start" on Apache
Move the project / website your doing into the following directory, make a folder name for it e.g. TestOne C:\xampp\htdocs
open Google Chrome or IE and put the following in the URL
localhost/TestOne/index.html
or whatever your index file of the website your making index.php etc..
You may need to run it on a server. You can make a local sever with tomcat. I hope this commit helps. You can always use a online website to emulate running it on your machine.
thanks,
adbadb25
When you are first learning how to code, I would start with a basic html format. Html,head, closing head,body, closing body,closing html. Inside the body tags, start with something simple. Opening and closing paragraphs tags. "Hello World".
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I recently changed some stuff on my website and i have just realised that an ajax script stopped working. I paid someone to code it so i really don't know how to debug it.
First here's how it's supposed to look.
If you click on a color, an AJAX script will call a PHP script to check the stock status for the selected color. If the answer is positive then the script will change the tshirt image to display the appropriate color.
The script works perfectly, but as soon as I use the same script on a subdomain it doesn't work. Here's an example of the same script on a subdomain.
The image won't change when a color is clicked.
I tried looking into Firefox Console but i can't find anything relevant.How can i find what's wrong ? Why the image doesn't change on the second link i provided ?
Second link has an error of "Origin http://hooded-sweatshirts.ni-dieu-ni-maitre.com is not allowed by Access-Control-Allow-Origin."
Refer: Origin is not allowed by Access-Control-Allow-Origin
Ajax call not work cross domain..
Below thread may help you..
Cross-domain $.ajax request is not working
I have found three problem on initial checkout of both your sites.
1 ) If you notice from the subdomain the request is going to the live site i.e https://www.ni-dieu-ni-maitre.com/tshirt_ajax.php?checkshop=429942&checkproducttype=111&stockcolor=5¤tsize=3
This should fetch the data from the subdomain site itself, so this url might be hardcoded somewhere in the script.
2 ) Script is trying to load the image from https to http and thus continuously giving error
3 ) Most of the js are loading from the live site onto sub-domain one and also might be a cause for the error occurring to your site.
try differentiating your test domain from live site i.e try not to call live resources from your test domain.. whether they are js or AJAX requests.
Regards