youtube url rel=0 is not working in javascript - javascript

youtube url is not working in javascript,why?
where is the mistake in my code:
$(document).ready(function(){
api_images = ['http://www.youtube.com/watchv=OyQoHmcunk&rel=0&fs=0&width=640&height=360'];
api_titles = ['Title 1'];
api_descriptions = ['']
$.prettyPhoto.open(api_images,api_titles,api_descriptions);
});

You're missing the ? that actually separates the path from the query-string:
api_images = ['http://www.youtube.com/watch?v=OyQoHmcunk&rel=0&fs=0&width=640&height=360'];
// ^
Without it, you should be receiving a 404 response, which a decent javascript debugger would've told you. You are using a debugger, right?
Also, depending on the DOCTYPE in use and whether this is from an inline or external <script>, HTML-encoding the &s may either be necessary or another source of issue:
api_images = ['http://www.youtube.com/watch?v=OyQoHmcunk&rel=0&fs=0&width=640&height=360'];
// ^ ^ ^ ^

Related

how to download file using jquery in asp.net core?

I use this code to download file using jquery.
$('#dwnlod').click(function (ee) {
e.preventDefault();
var currentFile = $('#SlideContainer .actv').css('background-image').replace(/^url|[\(\)]/g, '');
alert(currentFile)
document.location.href = currentFile;
});
However, it always does nothing. the reason for this is when I remove e.preventDefault to read the URL I find it distorted.
it rather than the result from alert >>
"https://localhost:660066/Uploads/5c92f430-4aef-41c8-b201-853597935771.jpg"
it displays in a new browser tab >>
https://localhost:660066/Documents/Index/"https://localhost:660066/Uploads/5c92f430-4aef-41c8-b201-853597935771.jpg"
I don't know if I need extra steps with asp.net core routing !!?
It looks like the issue is that currentFile returns a string that is surrounded by quotes and thus the browser is interpreting it as a relative URL (since the scheme isn't at the beginning of the string). Removing the start and end quotes if they exist should get you the behavior you are looking for.

Pass GET parameters to jsfiddle embedded version

I am using in my website the embedded version of a jsfiddle like so:
<script async src="//jsfiddle.net/mebibou/va5pu0bd/embed/"></script>
I tried to pass parameters in that url like ?foo=bar but I get an error in the console from the script on that url:
Uncaught TypeError: Cannot read property 'parentNode' of null
at createEmbedFrame (?foor=bar:19)
createEmbedFrame # ?foor=bar:19
setTimeout (async)
(anonymous) # ?foor=bar:43
(anonymous) # ?foor=bar:45
(you can see the code that is executed here: http://jsfiddle.net/mebibou/va5pu0bd/embed/?foo=bar)
I also tried to use the iframe version of the embed but it loads another iFrame within that removes the url parameter I put. Is it at all possible? what I want to do is pass parameters from my website to the jsfiddle code, and thought url params would be the easiest way
The error goes away if you remove the trailing slash from the path component:
<script async src="//jsfiddle.net/mebibou/va5pu0bd/embed/?foo=bar"></script>
^
<script async src="//jsfiddle.net/mebibou/va5pu0bd/embed?foo=bar"></script>
The error happens because the jsfiddle.net server strips such slash when composing the uriOriginal variable:
var uriOriginal = "http://jsfiddle.net/mebibou/va5pu0bd/embed?foo=bar"
That leads to a CSS selector that doesn't match your <script> tag:
var uriOriginal = "http://jsfiddle.net/mebibou/va5pu0bd/embed?foo=bar"
var uriOriginalNoProtocol = uriOriginal.split("//").pop()
var target = document.querySelector("script[src*='" + uriOriginalNoProtocol + "']")
console.log("script[src*='" + uriOriginalNoProtocol + "']", target);
However, if your <script> tags omits the slash then the selector does match.
It's worth nothing though that this hack merely prevents the error and allows the fiddle to load and run. It doesn't transmit the original URL parameters to the final iframe because its path is already hard-coded in the JavaScript code generated by the server:
var uriEmbedded = "http://jsfiddle.net/va5pu0bd/embedded/?username=mebibou")
iframe.src = uriEmbedded
target.parentNode.insertBefore(iframe, target.nextSibling)
To sum up, passing URL parameters is probably an unsupported scenario.

JavaScript Minifier Failed, probably because of ${

Getting below error :-
[com.liferay.portal.util.MinifierUtil] JavaScript Minifier failed for merlin.data['buyNow'] = merlin.data['buyNow'] || {} merlin.data['buyNow']['enhancements'] =
Corresponding source code from .jsp is ::
<script>
merlin.data['buyNow'] = merlin.data['buyNow'] || {}
merlin.data['buyNow']['${command.flavorType}'] = ${command.flavorsJSON}
</script>
I verified this code against online Minifier, ${command.flavorsJSON} probably has issue. Replacing this with some else like var1 works fine.
(Used : https://javascript-minifier.com/)
Yes you are right ${command.flavorsJSON} is the problem it should be like this: '${command.flavorsJSON}'. This way the expression Language part ${} will result in a string which then you can parse into an object if you wish

How to decode a JSFuck script?

I have this code in JavaScript:
[(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+
(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+
(!![]+[])[+!+[]]]
In the console, it will return
Array [ "filter" ]
And how can I decode a lot of text that’s similar to the text above? E.g.:
[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+
(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]][([][(![]+[])[+[]]+
([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+
(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+
(!![]+[][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+
(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+
([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+
(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+([![]]+[][[]])[+!+[]+[+[]]]+
(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+
(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+
([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+
(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]
I want to see the plain script.
I have seen many decoding attempts around, but none that work reliably. The easiest way I have found to decode Non Alphanumeric Javascript is with Chrome.
Open Chrome > Go to jsfuck.com > paste the code you would like to decode in the window > hit Run This.
Then open the Console, in the case of your specific code from PasteBin there will be an error:
Uncaught TypeError: Cannot read property 'innerHTML' of null
To the right of the error, click the line number link, and the code will be revealed. The result is:
(function(){
window.false=document.getElementById('sc').innerHTML;
})
Which explains why you get the error trying to just decode it using JSFuck itself. There is no element with the id sc on their site.
You can use this website to decode jsfuck:
http://codertab.com/jsunfuck
UPDATED
I extracted the decode javascript from the URL above, this is how the decode process work: (javascript)
s = source.slice(0, source.length - 2);
txtResult = eval(s);
Hope it help!
let elem = yourJSFuck
function decode(elem) {
return (/\n(.+)/.exec(eval(elem.replace(/\s+/, "").slice(0, -2)))[1]);
}
console.log(decode(elem))
This should work, the source is from this page

unexpected token error: in bookmarklet

The idea is to write a simple bookmarklet.
If the question is a possible duplicate kindly point me to it, because i was unsuccessful in finding.
I'm trying to make the current page jquery enabled using the bookmarklet and use certain jquery apis.
Uncaught SyntaxError: Unexpected token ILLEGAL
The above it the error I get using the below sample bookmarklet
javascript:(function(){
var d=document.createElement('script');
d.setAttribute('src', 'http://code.jquery.com/jquery-latest.js');
document.head.appendChild(d);
$('a').each(function(){
alert( $(this).attr('src') );
});
})()
​ If I execute the same code line-by-line in console it works.
Thanks in advance
To make the page wait until jQuery is fully loaded, add a load handler to the script element. This worked in my browser:
javascript:(function(){
var d=document.createElement('script');
d.src = 'http://code.jquery.com/jquery-latest.js';
d.onload = function(){ /* load handler here */
$('a').each(function(){
console.log( $(this).attr('href') );
});
};
document.getElementsByTagName('head')[0].appendChild(d);
})()
I changed your code a little bit (add the src attribute directly as property to the created script element, retrieve the head element in a more classical way, use console.log instead of alert and log the href attribute of all links).

Categories