SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Hybrid View

  1. #1
    SitePoint Member arclite86's Avatar
    Join Date
    Nov 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need help with javascript code

    I need too line break a javascript code:


    Code:
       javascript:(function(){var%20a=function(b,c,d){return%20a=document.getElementsByClassName?function(a,b,c){c=c||document;for(var%20g,d=c.getElementsByClassName(a),e=b?new%20RegExp('\\b'+b+'\\b','i'):null,f=[],h=0,i=d.length;i>h;h+=1)g=d[h],(!e||e.test(g.nodeName))&&f.push(g);return%20f}:document.evaluate?function(a,b,c){b=b||'*',c=c||document;for(var%20i,j,d=a.split('%20'),e='',f='http://www.w3.org/1999/xhtml',g=document.documentElement.namespaceURI===f?f:null,h=[],k=0,l=d.length;l>k;k+=1)e+='[contains(concat(\'%20\',%20@class,%20\'%20\'),%20\'%20'+d[k]+'%20\')]';try{i=document.evaluate('.//'+b+e,c,g,0,null)}catch(m){i=document.evaluate('.//'+b+e,c,null,0,null)}for(;j=i.iterateNext();)h.push(j);return%20h}:function(a,b,c){b=b||'*',c=c||document;for(var%20g,i,d=a.split('%20'),e=[],f='*'===b&&c.all?c.all:c.getElementsByTagName(b),h=[],j=0,k=d.length;k>j;j+=1)e.push(new%20RegExp('(^|\\s)'+d[j]+'(\\s|$)'));for(var%20l=0,m=f.length;m>l;l+=1){g=f[l],i=!1;for(var%20n=0,o=e.length;o>n&&(i=e[n].test(g.className),i);n+=1);i&&h.push(g)}return%20h},a(b,c,d)},b=function(a,b){if(-1==a.className.indexOf('x-grid3-row-selected')){var%20c=document.createEvent('MouseEvents');c.initMouseEvent('mousedown',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(c);var%20d=document.createEvent('MouseEvents');d.initMouseEvent('click',!0,!0,window,0,0,0,0,0,b,b,b,b,0,null),a.dispatchEvent(d)}};try{if(-1==window.location.href.indexOf('tweepi.com'))throw'';var%20c=document.createElement('script');c.textContent='window.fua();',(document.head||document.documentElement).appendChild(c),c.parentNode.removeChild(c);var%20d=a('x-grid3-rows','div',document.getElementById('tweepiGridDiv'));if(d.length<=0)return;b(d[0],!1),b(d[d.length-1],!0)}catch(e){alert('Something%20went%20wrong.%20Please%20make%20sure%20you%20are%20on%20a%20Tweepi.com%20page!%20'+e)}})();
    could somebody please help me with this

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,060
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Sure.

    You can do this on websites such as http://jsbeautifier.org/

    Code:
    javascript: (function () {
           var % 20a = function (b, c, d) {
               return %20a = document.getElementsByClassName ? function (a, b, c) {
                   c = c || document;
                   for (var % 20g, d = c.getElementsByClassName(a), e = b ? new % 20RegExp('\\b' + b + '\\b', 'i') : null, f = [], h = 0, i = d.length; i > h; h += 1) g = d[h], (!e || e.test(g.nodeName)) && f.push(g);
                   return %20f
               } : document.evaluate ? function (a, b, c) {
                   b = b || '*', c = c || document;
                   for (var % 20i, j, d = a.split('%20'), e = '', f = 'http://www.w3.org/1999/xhtml', g = document.documentElement.namespaceURI === f ? f : null, h = [], k = 0, l = d.length; l > k; k += 1) e += '[contains(concat(\'%20\',%20@class,%20\'%20\'),%20\'%20' + d[k] + '%20\')]';
                   try {
                       i = document.evaluate('.//' + b + e, c, g, 0, null)
                   } catch (m) {
                       i = document.evaluate('.//' + b + e, c, null, 0, null)
                   }
                   for (; j = i.iterateNext();) h.push(j);
                   return %20h
               } : function (a, b, c) {
                   b = b || '*', c = c || document;
                   for (var % 20g, i, d = a.split('%20'), e = [], f = '*' === b && c.all ? c.all : c.getElementsByTagName(b), h = [], j = 0, k = d.length; k > j; j += 1) e.push(new % 20RegExp('(^|\\s)' + d[j] + '(\\s|$)'));
                   for (var % 20l = 0, m = f.length; m > l; l += 1) {
                       g = f[l], i = !1;
                       for (var % 20n = 0, o = e.length; o > n && (i = e[n].test(g.className), i); n += 1);
                       i && h.push(g)
                   }
                   return %20h
               }, a(b, c, d)
           }, b = function (a, b) {
                   if (-1 == a.className.indexOf('x-grid3-row-selected')) {
                       var % 20c = document.createEvent('MouseEvents');
                       c.initMouseEvent('mousedown', !0, !0, window, 0, 0, 0, 0, 0, b, b, b, b, 0, null), a.dispatchEvent(c);
                       var % 20d = document.createEvent('MouseEvents');
                       d.initMouseEvent('click', !0, !0, window, 0, 0, 0, 0, 0, b, b, b, b, 0, null), a.dispatchEvent(d)
                   }
               };
           try {
               if (-1 == window.location.href.indexOf('tweepi.com')) throw '';
               var % 20c = document.createElement('script');
               c.textContent = 'window.fua();', (document.head || document.documentElement).appendChild(c), c.parentNode.removeChild(c);
               var % 20d = a('x-grid3-rows', 'div', document.getElementById('tweepiGridDiv'));
               if (d.length <= 0) return;
               b(d[0], !1), b(d[d.length - 1], !0)
           } catch (e) {
               alert('Something%20went%20wrong.%20Please%20make%20sure%20you%20are%20on%20a%20Tweepi.com%20page!%20' + e)
           }
       })();

  3. #3
    SitePoint Member arclite86's Avatar
    Join Date
    Nov 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks, do you also know how to turn this in too a button I do have a button code but i dont know how to combine it with the java function


    This is the button that i would like to combine:
    Code:
    var input=document.createElement("input");
    input.type="button";
    input.value="GreaseMonkey Button";
    input.onclick = showAlert;
    document.body.appendChild(input);
     
    function showAlert()
    {
        alert("Hello World");
    }

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,060
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Well the first thing you'll need to do is deal with all of the occurrences of %20
    These are normally spaces (the 20 is a hexadecimal representation of the ISO-Latin code point for the character).

    I would guess that that leaves you with this:

    Code:
    (function () {
           var a = function (b, c, d) {
               return a = document.getElementsByClassName ? function (a, b, c) {
                   c = c || document;
                   for (var g, d = c.getElementsByClassName(a), e = b ? new RegExp('\\b' + b + '\\b', 'i') : null, f = [], h = 0, i = d.length; i > h; h += 1) g = d[h], (!e || e.test(g.nodeName)) && f.push(g);
                   return f
               } : document.evaluate ? function (a, b, c) {
                   b = b || '*', c = c || document;
                   for (var i, j, d = a.split(' '), e = '', f = 'http://www.w3.org/1999/xhtml', g = document.documentElement.namespaceURI === f ? f : null, h = [], k = 0, l = d.length; l > k; k += 1) e += '[contains(concat(\' \', @class, \' \'), \' ' + d[k] + ' \')]';
                   try {
                       i = document.evaluate('.//' + b + e, c, g, 0, null)
                   } catch (m) {
                       i = document.evaluate('.//' + b + e, c, null, 0, null)
                   }
                   for (; j = i.iterateNext();) h.push(j);
                   return h
               } : function (a, b, c) {
                   b = b || '*', c = c || document;
                   for (var g, i, d = a.split(' '), e = [], f = '*' === b && c.all ? c.all : c.getElementsByTagName(b), h = [], j = 0, k = d.length; k > j; j += 1) e.push(new RegExp('(^|\\s)' + d[j] + '(\\s|$)'));
                   for (var l = 0, m = f.length; m > l; l += 1) {
                       g = f[l], i = !1;
                       for (var n = 0, o = e.length; o > n && (i = e[n].test(g.className), i); n += 1);
                       i && h.push(g)
                   }
                   return h
               }, a(b, c, d)
           }, b = function (a, b) {
                   if (-1 == a.className.indexOf('x-grid3-row-selected')) {
                       var c = document.createEvent('MouseEvents');
                       c.initMouseEvent('mousedown', !0, !0, window, 0, 0, 0, 0, 0, b, b, b, b, 0, null), a.dispatchEvent(c);
                       var d = document.createEvent('MouseEvents');
                       d.initMouseEvent('click', !0, !0, window, 0, 0, 0, 0, 0, b, b, b, b, 0, null), a.dispatchEvent(d)
                   }
               };
           try {
               if (-1 == window.location.href.indexOf('tweepi.com')) throw '';
               var c = document.createElement('script');
               c.textContent = 'window.fua();', (document.head || document.documentElement).appendChild(c), c.parentNode.removeChild(c);
               var d = a('x-grid3-rows', 'div', document.getElementById('tweepiGridDiv'));
               if (d.length <= 0) return;
               b(d[0], !1), b(d[d.length - 1], !0)
           } catch (e) {
               alert('Something went wrong. Please make sure you are on a Tweepi.com page!' + e)
           }
       })();
    You then need to make that a names function (as opposed to a self-executing one):

    Code:
    function myFunction () {
           var a = function (b, c, d) {
               return a = document.getElementsByClassName ? function (a, b, c) {
                   c = c || document;
                   for (var g, d = c.getElementsByClassName(a), e = b ? new RegExp('\\b' + b + '\\b', 'i') : null, f = [], h = 0, i = d.length; i > h; h += 1) g = d[h], (!e || e.test(g.nodeName)) && f.push(g);
                   return f
               } : document.evaluate ? function (a, b, c) {
                   b = b || '*', c = c || document;
                   for (var i, j, d = a.split(' '), e = '', f = 'http://www.w3.org/1999/xhtml', g = document.documentElement.namespaceURI === f ? f : null, h = [], k = 0, l = d.length; l > k; k += 1) e += '[contains(concat(\' \', @class, \' \'), \' ' + d[k] + ' \')]';
                   try {
                       i = document.evaluate('.//' + b + e, c, g, 0, null)
                   } catch (m) {
                       i = document.evaluate('.//' + b + e, c, null, 0, null)
                   }
                   for (; j = i.iterateNext();) h.push(j);
                   return h
               } : function (a, b, c) {
                   b = b || '*', c = c || document;
                   for (var g, i, d = a.split(' '), e = [], f = '*' === b && c.all ? c.all : c.getElementsByTagName(b), h = [], j = 0, k = d.length; k > j; j += 1) e.push(new RegExp('(^|\\s)' + d[j] + '(\\s|$)'));
                   for (var l = 0, m = f.length; m > l; l += 1) {
                       g = f[l], i = !1;
                       for (var n = 0, o = e.length; o > n && (i = e[n].test(g.className), i); n += 1);
                       i && h.push(g)
                   }
                   return h
               }, a(b, c, d)
           }, b = function (a, b) {
                   if (-1 == a.className.indexOf('x-grid3-row-selected')) {
                       var c = document.createEvent('MouseEvents');
                       c.initMouseEvent('mousedown', !0, !0, window, 0, 0, 0, 0, 0, b, b, b, b, 0, null), a.dispatchEvent(c);
                       var d = document.createEvent('MouseEvents');
                       d.initMouseEvent('click', !0, !0, window, 0, 0, 0, 0, 0, b, b, b, b, 0, null), a.dispatchEvent(d)
                   }
               };
           try {
               if (-1 == window.location.href.indexOf('tweepi.com')) throw '';
               var c = document.createElement('script');
               c.textContent = 'window.fua();', (document.head || document.documentElement).appendChild(c), c.parentNode.removeChild(c);
               var d = a('x-grid3-rows', 'div', document.getElementById('tweepiGridDiv'));
               if (d.length <= 0) return;
               b(d[0], !1), b(d[d.length - 1], !0)
           } catch (e) {
               alert('Something went wrong. Please make sure you are on a Tweepi.com page!' + e)
           }
    }
    
    var input=document.createElement("input");
    input.type="button";
    input.value="GreaseMonkey Button";
    input.onclick = myFunction;
    document.body.appendChild(input);

  5. #5
    SitePoint Member arclite86's Avatar
    Join Date
    Nov 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THANK you so much,It worked, I am looking for this for months, man I love you :-)

  6. #6
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,060
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    You're welcome

    Do you still want me to reply to your other thread?
    I didn't do so yet, as it means I have to create an account at tweepi.

  7. #7
    SitePoint Member arclite86's Avatar
    Join Date
    Nov 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no no you have solved all my problems I dont have questions anymore,
    again thank you VERY much!!

  8. #8
    SitePoint Member arclite86's Avatar
    Join Date
    Nov 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you want to help me for the last time, i have a small question:

    Code:
    var input=document.createElement("input");
    input.type="button";
    input.id="button";
    input.value="GreaseMonkey Button";
    input.onclick = myFunction;
    document.body.appendChild(input);
    I want to turn this instead of input to a div

    Is this the way i should do it ?

    Code:
    vardiv=document.createElement("div");
    div.type="button";
    div.id="button";
    div.value="GreaseMonkey Button";
    div.onclick = myFunction;
    document.body.appendChild(div);

  9. #9
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,060
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    A div cannot have a type or a value attribute.
    Why don't you use a real button?

    Or, just remove the type and value attributes altogether:

    Code:
    var div=document.createElement("div");
    div.id="button";
    div.innerHTML="GreaseMonkey Button";
    div.onclick = myFunction;
    document.body.appendChild(div);

  10. #10
    SitePoint Member arclite86's Avatar
    Join Date
    Nov 2013
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks , thanks too you i solved that too

    Last edited by Mittineague; Mar 21, 2014 at 08:48.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •