Last active
August 29, 2015 14:15
-
-
Save sash13/f411ea05615412fea3f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Plusach rulet | |
| // @description Random post goes to top | |
| // @author Tsumugi Kotobuki | |
| // @license MIT | |
| // @version 0.01 | |
| // @include https://plus.google.com/* | |
| // ==/UserScript== | |
| function exchangeElements(element1, element2) | |
| { | |
| var clonedElement1 = element1.cloneNode(true); | |
| var clonedElement2 = element2.cloneNode(true); | |
| element2.parentNode.replaceChild(clonedElement1, element2); | |
| element1.parentNode.replaceChild(clonedElement2, element1); | |
| return clonedElement1; | |
| } | |
| (function (window, undefined) { | |
| var w; | |
| if (typeof unsafeWindow != undefined) { | |
| w = unsafeWindow | |
| } else { | |
| w = window; | |
| } | |
| addButton = function() | |
| { | |
| myButton = document.createElement("span"); | |
| myButton.setAttribute("class", "d-s Cy"); | |
| myButton.setAttribute("id", "rulet"); | |
| myButton.setAttribute("tabindex", "0"); | |
| myButton.setAttribute("role","button"); | |
| myButton.innerHTML = "Rulet!"; | |
| myButton.onclick = function() | |
| { | |
| var coll; | |
| if(document.getElementsByClassName('Ypa jw gb am') !== undefined) | |
| { | |
| coll = document.getElementsByClassName('Ypa jw gb am'); | |
| } | |
| if (document.getElementsByClassName('Ypa jw Ic am') !== undefined) | |
| { | |
| coll = document.getElementsByClassName('Ypa jw Ic am'); | |
| } | |
| if(document.getElementsByClassName('Ypa jw Yc am') !== undefined) | |
| { | |
| coll = document.getElementsByClassName('Ypa jw Yc am'); | |
| } | |
| var test = document.getElementsByClassName('Yp yt Xa'); | |
| exchangeElements(test[0], test[Math.floor((Math.random() * test.length) + 1)]); | |
| console.log(coll); | |
| var coll1 = coll[0].getElementsByClassName('Yp yt Xa'); | |
| var coll2 = coll[1].getElementsByClassName('Yp yt Xa'); | |
| var coll3 = coll[2].getElementsByClassName('Yp yt Xa'); | |
| /*if (coll.length <= 4) | |
| { | |
| exchangeElements(test[0], test[Math.floor((Math.random() * test.length) + 1)]); | |
| } | |
| else if (coll.length > 4) | |
| {*/ | |
| exchangeElements(test[coll1.length], test[Math.floor((Math.random() * test.length) + 1)]); | |
| exchangeElements(test[coll1.length+coll2.length], test[Math.floor((Math.random() * test.length) + 1)]); | |
| //} | |
| } | |
| placeHolder = h = document.getElementsByClassName("Ima Xic")[0]; | |
| placeHolder.appendChild(myButton); | |
| } | |
| if (w.self != w.top) { | |
| return; | |
| } | |
| addButton(); | |
| setInterval(function() | |
| { | |
| if(!document.getElementById("rulet")) | |
| addButton(); | |
| }, 3000); | |
| })(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment