Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // programmers day
- if ("100"===Math.ceil(((d=new Date())-(new Date(d.getFullYear(),0,1)))/864e+5).toString(16)){
- console.log("party hard");
- }else {
- // do nothing
- }
- // xPath javascript helper
- function xPathFunct(xPathExp){
- var resXPath = document.evaluate(xPathExp, document, null, XPathResult.ANY_TYPE, null);
- var result=resXPath.iterateNext();
- var resArray = [];
- while (result){
- resArray.push(result);
- result=resXPath.iterateNext();
- }
- return resArray;
- }
- // delete all records from vkontakte responce panel by specific user
- i=1;xPathFunct("//div[@class='post_like_wrap fl_r']").forEach(function(d){if(/85555558/.test(d.outerHTML)){i++;setTimeout("d.onclick.apply(d)",1000*i);}})
- // define property for quick access
- Object.defineProperty(Element.prototype,"_",{ get : function(){return this.childNodes;} })
- // another way to iterate
- for (var i= element.childNodes.length-1; i>=0;i--) {
- for (var i= element.childNodes.length; i-->0;) {
- // collect vk friend to one list (here html class property handle correct)
- (function collect(){var d={};xPathFunct("//div[contains(@class, 'user_block') and contains(@class, 'clear_fix')]/div[1]/div[2]/a[1]").forEach(function(a){console.log(a); d[a.href]=a.innerHTML;}); return d;})()
- // return unique properties of two object
- function comp(ob1, ob2){
- for(a in ob1){
- if(a in ob1 && a in ob2){
- delete ob2[a];
- delete ob1[a];
- }
- }
- return [ob1,ob2];
- }
- comp({a:1,b:2},{a:2,c:4})
- // scriptlet clicker by conditions
- Array.prototype.slice.call(document.getElementsByTagName('span')).filter(function(a){return /^exlink/.test(a.id);}).forEach(function(a){var link = a.getElementsByTagName('a')[0]; setTimeout(function(){link.onclick.apply(link)},100)});
- // e-mail regexp
- [a-zA-Z0-9_.-]+@[a-zA-Z0-9_-]+\.[a-zA-Z].
- // javascript string from char codes
- String.fromCharCode(1087).concat(String.fromCharCode(1088)).concat(String.fromCharCode(1080)).concat(String.fromCharCode(1074)).concat(String.fromCharCode(1077)).concat(String.fromCharCode(1090));
- // css positions demo
- http://jsfiddle.net/zYZRC/
- // some xss vector
- <meta http-equiv="refresh" content="0;url='http://google.com/search?q=qweqwe'">
- <META HTTP-EQUIV="refresh" CONTENT="0;url=javascript:alert('XSS');">
- // valid XML
- <script>
- /*<![CDATA[*/
- function ololo(ip,sel,sz){
- }
- /*]]>*/
- </script>
- // xml parser
- parser=new DOMParser();
- str = '<?xml version="1.0" ?> <note><to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Dont forget me this weekend!</body> </note>';
- xmlDoc=parser.parseFromString(str,"text/xml");
- // array average
- Array.prototype.avg = function() {
- var av = 0;
- var cnt = 0;
- var len = this.length;
- for (var i = 0; i < len; i++) {
- var e = this[i];
- if (isFinite(e)){
- av += e;
- cnt++;
- }
- }
- if(cnt==0) return;
- return av/cnt;
- }
- // Enums in javascript
- function Enum() {
- for (var i in arguments) {
- var cur = arguments[i];
- this[cur] = cur;
- }
- Object.freeze(this)
- }
- var YesNo = new Enum('Yes', 'No');
- // from string to charcodes
- (function(data){
- res = []
- for(i=0;i<data.length;i++){
- res.push(data[i].charCodeAt(0));
- }
- // usage: String.fromCharCode(60, 105);
- return res;
- })("http://")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement