Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==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);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement