AyrA icon

Anti Rickroll

AyrA | PRO | 12/06/16 08:07:57 AM UTC | 0 ⭐ | 557 👁️ | Never ⏰ | []
JavaScript |

1.09 KB

|

None

|

0 👍

/

0 👎

// ==UserSacript==
// @name         Anti Rickroll
// @namespace    http://ayra.ch/
// @version      0.1
// @description  Warns you about being rickrolled
// @author       /u/AyrA_ch
// @include http://*/*
// @include https://*/*
// @grant        none
// ==/UserScript==
 
(function() {
    'use strict';
    //this matches youtube URLs for the video with ID dQw4w9WgXcQ
    var filter=/(?:youtu\.be\/|youtube(-nocookie)?.com\/(?:v\/|e\/|.*u\/\w+\/|embed\/|.*v=))(dQw4w9WgXcQ)/;
    var scanRickRoll=function(){
        var a=document.querySelectorAll("a");
        for(var i=0;i<a.length;i++)
        {
            if(a[i].href && a[i].href.match(filter))
            {
                a[i].innerHTML="<b>Probably rickroll</b>";
            }
        }
    };
    var timer=false;
    var scheduleUpdater=function(){
        if(!timer)
        {
            timer=window.setTimeout(function(){scanRickRoll();timer=false;},500);
        }
    };
    scanRickRoll();
    document.body.addEventListener('DOMSubtreeModified', function (){
        scheduleUpdater();
    }, false);
})();

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎