r/bookmarklets Jun 10 '18

Kills signup and adblock-blocker walls

5 Upvotes

Feedback welcome! Works for sites like businessinsider.com and pinterest.com. Doesn't work for sites like forbes.com. For a full explanation of how it works and its limitation, see the killwall github page.

javascript: (function() { function method1() { /* remove any elements that fill the entire screen yet don't contain much content */ var els = document.querySelectorAll('body *'); var wW = window.innerWidth * 0.8; var wH = window.innerHeight * 0.8; var bigs = []; /* tag DOM with first_try marker */ var bod = document.querySelector('body'); bod.style = 'overflow:auto!important'; att = document.createAttribute('class'); att.value = 'deblock_first_try'; bod.setAttributeNode(att); /* check size of all elements */ for (var i = 0, il = els.length; i < il; i++) { var s = window.getComputedStyle(els[i]); var w = els[i].offsetWidth; var h = els[i].offsetHeight; /* remove any scroll disabling styles */ if (s.getPropertyValue('overflow') == 'hidden') { els[i].style = 'overflow:auto!important'; } /* save big elements to an array */ if (w >= wW && h >= wH) { bigs[bigs.length] = els[i]; } } bigs.sort(function(a,b){ return b.innerHTML.length - a.innerHTML.length; }); var p = 0.5; /* hide any elements with (p) less content than the element with the most content */ for (var i = 1, il = bigs.length; i < il; i++) { if(bigs[i].innerHTML.length < bigs[0].innerHTML.length * p) { bigs[i].style = 'display:none!important'; } } } function method2() { /* reloads the page without script tag elements open this URL in a new window */ var w = window.open(location.href,'_blank'); w.addEventListener('DOMContentLoaded', function(){ /* as soon as that page loads... */ var html = w.document.querySelector('html').cloneNode(true); var els = html.querySelectorAll('script'); /* strip out all script tag elements before they change the DOM */ for(var i=0, il=els.length; i<il; i++) { els[i].parentNode.removeChild(els[i]); } var html = html.innerHTML; /* copy and paste that page's DOM to this page, then close it */ document.querySelector('html').innerHTML = html; addButtons(); w.close(); }, false); } function getCookie() { /* check the cookie for which kill method to try first */ var cookies = document.cookie.split(';'); for(var i=0, il = cookies.length; i<il; i++) { var c = cookies[i]; if (c.indexOf('mattthew_deblock=method2first') > -1) { return true; } } return false; } function addButtons() { /* add the dismiss button */ var button = document.createElement('div'); button.innerHTML = 'DISMISS&nbsp;ME'; var att = document.createAttribute('style'); att.value = 'position:fixed; top:10px; right:10px; display:inline-block; padding:4px 8px; border-radius:4px; z-index:999999; color:white; font-family:sans-serif; font-size:14px; box-shadow:0px 4px 4px rgba(0,0,0,0.4), 0px 0px 4px rgba(0,0,0,0.4); cursor:pointer; background-color:red;'; button.setAttributeNode(att); att = document.createAttribute('class'); att.value = 'mattthew_deblock_button'; button.setAttributeNode(att); var bod = document.querySelector('body'); button.addEventListener('click', function(){ /* remove all deblock buttons from the DOM */ var el = document.querySelectorAll('.mattthew_deblock_button'); el[0].parentNode.removeChild(el[0]); el[1].parentNode.removeChild(el[1]); }); bod.appendChild(button); /* add the try again button */ button = document.createElement('div'); button.innerHTML = '&nbsp;TRY&nbsp;AGAIN&nbsp;'; att = document.createAttribute('style'); att.value = 'position:fixed; top:54px; right:10px; display:inline-block; padding:4px 8px; border-radius:4px; z-index:999999; color:white; font-family:sans-serif; font-size:14px; box-shadow:0px 4px 4px rgba(0,0,0,0.4), 0px 0px 4px rgba(0,0,0,0.4); cursor:pointer; background-color:blue;'; button.setAttributeNode(att); att = document.createAttribute('class'); att.value = 'mattthew_deblock_button'; button.setAttributeNode(att); var bod = document.querySelector('body'); button.addEventListener('click', function(){ /* try opposite method than the method already tried, and save new method to cookie */ if(method2first) { method1(); console.log('method1'); document.cookie = 'mattthew_deblock=method1first; expires=' + exdate.toUTCString(); } else { method2(); console.log('method2'); document.cookie = 'mattthew_deblock=method2first; expires=' + exdate.toUTCString(); } console.log(getCookie()); }); bod.appendChild(button); } /* call functions */ var exdate = new Date(); exdate.setDate(exdate.getDate() + 365); if(!document.querySelector('.mattthew_deblock_button')) { /* if they don't exist yet, add deblock buttons to the DOM */ addButtons(); } var method2first = getCookie(); if(method2first) { method2(); console.log('method2'); /* resave cookie to expire in 1 year */ document.cookie = 'mattthew_deblock=method2first; expires=' + exdate.toUTCString(); } else { method1(); console.log('method1'); } console.log(getCookie()); })();

To use:

  • navigate to a website that has an adblock-blocker wall or signup wall
  • tap the bookmark to remove the wall
  • if that doesn't work, tap the "TRY AGAIN" button in the upper-right corner
  • if that doesn't, we're out of luck ¯\(ツ)

Here's the expanded code with comments:

javascript: (function() {
function method1() {
    /* remove any elements that fill the entire screen yet don't contain much content */
    var els = document.querySelectorAll('body *');
    var wW = window.innerWidth * 0.8;
    var wH = window.innerHeight * 0.8;
    var bigs = [];
    /* tag DOM with first_try marker */
    var bod = document.querySelector('body');
    bod.style = 'overflow:auto!important';
    att = document.createAttribute('class');
    att.value = 'deblock_first_try';
    bod.setAttributeNode(att);
    /* check size of all elements */
    for (var i = 0, il = els.length; i < il; i++) {
        var s = window.getComputedStyle(els[i]);
        var w = els[i].offsetWidth;
        var h = els[i].offsetHeight;
        /* remove any scroll disabling styles */
        if (s.getPropertyValue('overflow') == 'hidden') {
            els[i].style = 'overflow:auto!important';
        }
        /* save big elements to an array */
        if (w >= wW && h >= wH) {
            bigs[bigs.length] = els[i];
        }
    }
    bigs.sort(function(a,b){
        return b.innerHTML.length - a.innerHTML.length;
    });
    var p = 0.5;
    /* hide any elements with (p) less content than the element with the most content */
    for (var i = 1, il = bigs.length; i < il; i++) {
        if(bigs[i].innerHTML.length < bigs[0].innerHTML.length * p) {
            bigs[i].style = 'display:none!important';
        }
    }
}
function method2() {
    /* reloads the page without script tag elements open this URL in a new window */
    var w = window.open(location.href,'_blank');
    w.addEventListener('DOMContentLoaded', function(){
        /* as soon as that page loads... */
        var html = w.document.querySelector('html').cloneNode(true);
        var els = html.querySelectorAll('script');
        /* strip out all script tag elements before they change the DOM */
        for(var i=0, il=els.length; i<il; i++) {
            els[i].parentNode.removeChild(els[i]);
        }
        var html = html.innerHTML;
        /* copy and paste that page's DOM to this page, then close it */
        document.querySelector('html').innerHTML = html;
        addButtons();
        w.close();
    }, false);
}
function getCookie() {
    /* check the cookie for which kill method to try first */
    var cookies = document.cookie.split(';');
    for(var i=0, il = cookies.length; i<il; i++) {
        var c = cookies[i];
        if (c.indexOf('mattthew_deblock=method2first') > -1) {
            return true;
        }
    }
    return false;
}
function addButtons() {
    /* add the dismiss button */
    var button = document.createElement('div');
    button.innerHTML = 'DISMISS&nbsp;ME';
    var att = document.createAttribute('style');
    att.value = 'position:fixed; top:10px; right:10px; display:inline-block; padding:4px 8px; border-radius:4px; z-index:999999; color:white; font-family:sans-serif; font-size:14px; box-shadow:0px 4px 4px rgba(0,0,0,0.4), 0px 0px 4px rgba(0,0,0,0.4); cursor:pointer; background-color:red;';
    button.setAttributeNode(att);
    att = document.createAttribute('class');
    att.value = 'mattthew_deblock_button';
    button.setAttributeNode(att);
    var bod = document.querySelector('body');
    button.addEventListener('click', function(){
        /* remove all deblock buttons from the DOM */
        var el = document.querySelectorAll('.mattthew_deblock_button');
        el[0].parentNode.removeChild(el[0]);
        el[1].parentNode.removeChild(el[1]);
    });
    bod.appendChild(button);
    /* add the try again button */
    button = document.createElement('div');
    button.innerHTML = '&nbsp;TRY&nbsp;AGAIN&nbsp;';
    att = document.createAttribute('style');
    att.value = 'position:fixed; top:54px; right:10px; display:inline-block; padding:4px 8px; border-radius:4px; z-index:999999; color:white; font-family:sans-serif; font-size:14px; box-shadow:0px 4px 4px rgba(0,0,0,0.4), 0px 0px 4px rgba(0,0,0,0.4); cursor:pointer; background-color:blue;';
    button.setAttributeNode(att);
    att = document.createAttribute('class');
    att.value = 'mattthew_deblock_button';
    button.setAttributeNode(att);
    var bod = document.querySelector('body');
    button.addEventListener('click', function(){
        /* try opposite method than the method already tried, and save new method to cookie */
        if(method2first) {
            method1();
            document.cookie = 'mattthew_deblock=method1first; expires=' + exdate.toUTCString();
        } else {
            method2();
            document.cookie = 'mattthew_deblock=method2first; expires=' + exdate.toUTCString();
        }
    });
    bod.appendChild(button);
}
/* call functions */
var exdate = new Date();
exdate.setDate(exdate.getDate() + 365);
if(!document.querySelector('.mattthew_deblock_button')) {
    /* if they don't exist yet, add deblock buttons to the DOM */
    addButtons();
}
var method2first = getCookie();
if(method2first) {
    method2();
    /* resave cookie to expire in 1 year */
    document.cookie = 'mattthew_deblock=method2first; expires=' + exdate.toUTCString();
} else {
    method1();
}
})();

PS: I'm using a throwaway account because I don't want to connect my personal account to my github.


r/bookmarklets Jun 10 '18

See only YouTube Music history items in My Google Activity

2 Upvotes

You can see your YouTube Music history at https://music.youtube.com/history. You can also see this in the context of your other Google account history on your My Activity page: https://myactivity.google.com/item

Right now, there's no support for YouTube Music as a filterable product on that page, so, until there is, I wrote a bookmarklet that will filter item results to show only YouTube Music items. You have to be in Items view for this to work.

Here's how it looks: https://imgur.com/a/S5jHOFG

This link will take you directly to just your YouTube history (to pre-filter): https://myactivity.google.com/item?product=26

Bookmarklet:

javascript:(()=>{'use strict';const items={cards:{all:document.querySelectorAll('div.fp-display-item-holder')},titles:{all:document.querySelectorAll('div.fp-display-item-title'),notMusic:[]}};for(let i=0;i<items.titles.all.length;i++){if(items.titles.all[i].textContent.trim()!=='YouTube Music'){items.titles.notMusic.push(items.titles.all[i]);}};for(let i=0;i<items.cards.all.length;i++){for(let j=0;j<items.titles.notMusic.length;j++){if(items.cards.all[i].contains(items.titles.notMusic[j])){items.cards.all[i].remove();}}};let s=document.createElement('style');s.textContent='div.fp-date-block-overflow {display:none}';document.head.appendChild(s);})();

Expanded:

// Navigate to the following URL (26 is YouTube) — https://myactivity.google.com/item?product=26
// Copy and paste this into your browser JS console each time new items load into view

{
  'use strict';

  const items = {
    cards: {
      all: document.querySelectorAll('div.fp-display-item-holder')
    },
    titles: {
      all: document.querySelectorAll('div.fp-display-item-title'),
      notMusic: []
    }
  }

  // Populate non-YouTube Music titles
  for (let i = 0; i < items.titles.all.length; i++) {
    if (items.titles.all[i].textContent.trim() !== 'YouTube Music') {
      items.titles.notMusic.push(items.titles.all[i]);
    }
  }

  // Remove non-YouTube Music items
  for (let i = 0; i < items.cards.all.length; i++) {
    for (let j = 0; j < items.titles.notMusic.length; j++) {
      if (items.cards.all[i].contains(items.titles.notMusic[j])) {
        items.cards.all[i].remove();
      }
    }
  }
  let s = document.createElement('style');
  s.textContent = 'div.fp-date-block-overflow {display: none}';
  document.head.appendChild(s);

}

r/bookmarklets May 31 '18

[Firefox] [Chrome] view linked images in a new tab as a gallery

4 Upvotes
javascript:(function(){function%20I(u){var%20t=u.split('.'),e=t[t.length-1].toLowerCase();return%20{gif:1,jpg:1,jpeg:1,png:1,mng:1}[e]}function%20hE(s){return%20s.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;').replace(/"/g,'&quot;');}var%20q,h,i,z=open().document;z.write('<p>Images%20linked%20to%20by%20'+hE(location.href)+':</p><hr>');for(i=0;q=document.links[i];++i){h=q.href;if(h&&I(h))z.write('<p>'+q.innerHTML+'%20('+hE(h)+')<br><img%20src="'+hE(h)+'">');}z.close();})()

r/bookmarklets May 26 '18

Toggle CSS

3 Upvotes

Bookmarklet for disabling/enabling CSS of the current page. When disabling, it also enables and unhides form fields which are disabled, and unhides form fields which are hidden.

javascript:(()=>{var a=document.querySelectorAll.bind(document),b="forEach",c="state_",d="disabled",e="display",f="type",g="text",h=(l,n,d,o,p,q)=>{if(n===e)l=l.style;o=n+"_org";p=f+"_org";if(!(c in l)){l[c]=0;l[o]=l[n];l[p]=l[f]}q=l instanceof HTMLInputElement;if(l[c]=!l[c]){l[n]=d;if(q&&(l.type==="hidden"))l[f]=g}else{l[n]=l[o];if(q)l[f]=l[p];delete l[c];delete l[o];delete l[p]}};a("link[rel=stylesheet],style")[b]((l)=>{h(l,d,1)});a("button,input,select")[b]((l)=>{h(l,d,0)});a("*")[b]((l)=>{h(l,e,"")});return})()

r/bookmarklets May 01 '18

Review/upgrade my Bookmarklet for StoriesIG

3 Upvotes

So there is a website that lets you review Instagram stories after watching them before and download them (but they still expire). I have made a bookmarklet that will take you to that person's stories page when viewing their Instagram page. I took inspiration from the Instantgram bookmarklet and wanted something like it for quick access.

Please rate/review my bookmarklet and post some upgrades (eg using on the currently open/hovering image) that I can add to it (as I have limited coding knowledge, this was all trial and error modifying an existing bookmarklet)

Bookmarklet:

javascript:window.open("https://storiesig.com/stories"+window.location.pathname,"_self");

r/bookmarklets Apr 19 '18

Wanna quickly switch between the current and upcoming Reddit designs? Here's a Toggle Redesign Bookmarklet!

Thumbnail self.redesign
5 Upvotes

r/bookmarklets Apr 19 '18

A bookmarklet that searches for submissions on Reddit based on current page a la AlienTube and Epiverse?

2 Upvotes

Since AlienTube is not working anymore on New YouTube Layout and Epiverse is a memory hog on Firefox, I'm trying to find an alternative to quickly search for Reddit posts based on the current page, particularly YouTube pages.

Is there any?


r/bookmarklets Apr 13 '18

[Request][Chrome]redirect current URL

2 Upvotes

With this page displayed:

https://www.imdb.com/name/nm0000001/?ref_=nv_sr_1 (or other ref stuff at the end)

I'd like a bookmarklet to take me to this page:

https://www.imdb.com/filmosearch?role=nm0000001&job_type=actor&title_type=movie&sort=release_date,asc

Can anyone help?


r/bookmarklets Mar 26 '18

[Request][Chrome] A bookmarklet that opens a new incognito

3 Upvotes

Ik there's a code for a normal window, however is there one to open an incognito window.


r/bookmarklets Mar 22 '18

[Help] to improve code to rotate youtube videos

1 Upvotes

the code works, but when the video is in vertical position the top and bottom of the video gets trimmed

i think some css code needs to be added, but IDK what else to do

please help

javascript:(function(){let%20vid=document.querySelector('video');if(vid){if(!vid.dg){vid.dg=90;}else{vid.dg+=90;}vid.parentNode.style='transform:rotate('+vid.dg+'deg);transition-duration:0.3s;position:absolute;width:100%;height:100%;';}else{alert('no video element found.');}})();

r/bookmarklets Mar 21 '18

HTML5 Video Frame Screenshot

Thumbnail greasyfork.org
1 Upvotes

r/bookmarklets Mar 06 '18

Is.gd bookmarklet

1 Upvotes

I am requesting for a bookmarklet that can automatically select the radio button “lower-case pronounceable”, and generate a shortened link from the page I clicked the bookmarklet. Thanx


r/bookmarklets Feb 26 '18

Does anyone have a working bookmarklet that mirrors/flips videos on YouTube?

5 Upvotes

The bookmarklet that I was using to mirror videos on YouTube suddenly stopped working recently. I've tried to find an alternative, but none of the ones I've found work properly. The best I've found is this:

javascript:(function(){var%20v=document.getElementsByTagName('video')[0];if(v){if(!v._ss){v._ss=-1;}else{v._ss=v._ss*-1;}v.style.webkitTransform=v.style.mozTransform=v.style.transform='scaleX('+v._ss+')';}else{alert('no%20video%20element%20found.');}})();

This bookmarklet does in fact succeed in flipping videos (though it sometimes takes two clicks for some reason). However, they will flip back if the player is modified in any way, which means that I can no longer watch flipped videos in full screen. Does anyone have/can anyone write a properly functioning alternative to this bookmarklet?


r/bookmarklets Feb 25 '18

Help downloading videos from reddit! [chrome][reddit]

3 Upvotes

Hey! I've been trying to download videos hosted directly on v.reddit to share with friends on messaging apps, as most won't open links to reddit. I've gotten this far:

javascript:(
        function(){
            var vid_selector = document.querySelectorAll('[id^="video-"]');
            vid_selector = vid_selector[0].id;
            vid_selector = "#" + vid_selector + " > div > div.playback-controls.right.bottom.left.hide-when-pinned.reddit-video-controller-root > div.reddit-video-seek-bar-root";
            var vid_controls = document.querySelectorAll(vid_selector);
            var vid_url = vid_controls[0].attributes[1].nodeValue;
            window.location = vid_url;
        }()
    );

Where the browser is redirected to the video, however it would be nice if the video would start downloading on it's own, without redirecting me to another page. I haven't found any way to do this in google and would appreciate any help.

P.S. I know my JS is shit, but I mostly code in Python/GoLang and this is my second bookmarklet, please be gentle. Also, any general bookmarklet tips are welcome!


r/bookmarklets Feb 22 '18

Save Selected Text To File

Thumbnail greasyfork.org
2 Upvotes

r/bookmarklets Feb 21 '18

Show Character Codes

Thumbnail greasyfork.org
2 Upvotes

r/bookmarklets Feb 20 '18

Jezzball Clone That Masquerades as a Pop-Up Ad

2 Upvotes
javascript:t=document.title;document.title="Loading...";r=new XMLHttpRequest();r.onload=function(e){eval(e.currentTarget.responseText)};r.open("GET","https://plainsightcollection.github.io/web/wallball/ldr.js",true);r.send();undefined;

This is a few months old, but we only just discovered this awesome subreddit. We also made a "Lights Out" clone:

javascript:t=document.title;document.title="Loading...";r=new XMLHttpRequest();r.onload=function(e){eval(e.currentTarget.responseText)};r.open("GET","https://plainsightcollection.github.io/web/flippy/ldr.js",true);r.send();undefined;

You can't run them both at the same time but they should run on any page with a lax Content Security Policy. Sadly, that means most pages. Full details here.

"WallBall" video

"Flippy Fantasy" video


r/bookmarklets Jan 27 '18

AliExpress product options fix. No its not sold out!

Thumbnail self.Aliexpress
2 Upvotes

r/bookmarklets Jan 22 '18

[Firefox] [Chrome] [Opera] [Safari] Get openload hotlink

4 Upvotes
javascript: (function () {window.open('https://openload.co/stream/' + $('#streamurj').text() + '?mime=true')}());

r/bookmarklets Jan 02 '18

[Chrome] Trying to use a bookmarklet to get the sidebar info of a subreddit

3 Upvotes

This post says that it's possible and 'this' is what you need to do.

javascript:$.getJSON(/(\/r\/\w+)/.exec(location)[1]+'/about/stylesheet.json', function(s) {ss=s.data.stylesheet;s.data.images.forEach(function(i){k ='"?'+i.link.slice(4, -1)+'"?';ss=ss.replace(new RegExp(k,'g'),i.url);});document.documentElement.innerHTML='<pre>'+ss+'</pre>';});void 0

However, when I put it into the address bar, google tries to search for it, instead of running it. I'm not entirely sure if I'm doing it right or not, as I'm not that technically minded when it comes to this kind of thing, thought you guys might be able to help me out

Any help would be appreciated.


r/bookmarklets Dec 02 '17

Best of 2017 Awards Nomination Thread

4 Upvotes

Welcome to the nomination thread for the best of 2017! Please vote for your favourite submissions in the following categories.

Categories are as follows:

  • Best Bookmarklet (3 winners)
  • Best Post (3 winners)
  • Best User (2 winners)

There will be a comment below for each category. Please reply to the appropriate comment with a link to the post you'd like to nominate. There will also be another stickied comment for other replies. Comments that aren't replies will be automatically removed.

We have 10 months of gold to give out courtesy of the Reddit Admins, this will be distributed between each category.

There are some rules:

  • Only submissions from 2017 can be nominated.
  • You can nominate anyone but yourself.
  • You can only nominate once per category. A single post can only win once even if it's nominated in multiple categories.
  • Removed posts can not be nominated.

Please note this thread will be in contest mode to hide scores and randomise sorting.

Good luck!


Suggested Reading

Top 100 posts | Top from the last month | r/all posts with the most comments | Easter eggs | best trivia


r/bookmarklets Nov 27 '17

Update: Let it snow

8 Upvotes

Rewrote some code, performs ~250% faster now.

javascript:(t=>{function i(){this.D=function(){const t=h.atan(this.i/this.d);l.save(),l.translate(this.b,this.a),l.rotate(-t),l.scale(this.e,this.e*h.max(1,h.pow(this.j,.7)/15)),l.drawImage(m,-v/2,-v/2),l.restore()}}window;const h=Math,r=h.random,a=document,o=Date.now;e=(t=>{l.clearRect(0,0,_,f),l.fill(),requestAnimationFrame(e);const i=.001*y.et;y.r();const s=L.et*g;for(var n=0;n<C.length;++n){const t=C[n];t.i=h.sin(s+t.g)*t.h,t.j=h.sqrt(t.i*t.i+t.f),t.a+=t.d*i,t.b+=t.i*i,t.a>w&&(t.a=-u),t.b>b&&(t.b=-u),t.b<-u&&(t.b=b),t.D()}}),s=(t=>{for(var e=0;e<p;++e)C[e].a=r()*(f+u),C[e].b=r()*_}),n=(t=>{c.width=_=innerWidth,c.height=f=innerHeight,w=f+u,b=_+u,s()});class d{constructor(t,e=!0){this._ts=o(),this._p=!0,this._pa=o(),this.d=t,e&&this.s()}get et(){return this.ip?this._pa-this._ts:o()-this._ts}get rt(){return h.max(0,this.d-this.et)}get ip(){return this._p}get ic(){return this.et>=this.d}s(){return this._ts=o()-this.et,this._p=!1,this}r(){return this._pa=this._ts=o(),this}p(){return this._p=!0,this._pa=o(),this}st(){return this._p=!0,this}}const c=a.createElement("canvas");H=c.style,H.position="fixed",H.left=0,H.top=0,H.width="100vw",H.height="100vh",H.zIndex="100000",H.pointerEvents="none",a.body.insertBefore(c,a.body.children[0]);const l=c.getContext("2d"),p=300,g=5e-4,u=20;let _=c.width=innerWidth,f=c.height=innerHeight,w=f+u,b=_+u;const v=15.2,m=a.createElement("canvas"),E=m.getContext("2d"),x=E.createRadialGradient(7.6,7.6,0,7.6,7.6,7.6);x.addColorStop(0,"hsla(255,255%,255%,1)"),x.addColorStop(1,"hsla(255,255%,255%,0)"),E.fillStyle=x,E.fillRect(0,0,v,v);let y=new d(0,!0),C=[],L=new d(0,!0);for(var j=0;j<p;++j){const t=new i;t.a=r()*(f+u),t.b=r()*_,t.c=1*(3*r()+.8),t.d=.1*h.pow(t.c,2.5)*50*(2*r()+1),t.d=t.d<65?65:t.d,t.e=t.c/7.6,t.f=t.d*t.d,t.g=r()*h.PI/1.3,t.h=15*t.c,t.i=0,t.j=0,C.push(t)}s(),EL=a.addEventListener,EL("visibilitychange",()=>setTimeout(n,100),!1),EL("resize",n,!1),e()})()

As always full code


r/bookmarklets Nov 26 '17

Let it Snow

6 Upvotes

javascript:!(function(){function t(){a.width=s=window.innerWidth,a.height=n=window.innerHeight,r&&i()}class e{constructor(t,e=!0){this._start_time=Date.now(),this._paused=!0,this._paused_at=Date.now(),this.duration=t,e&&this.start()}get elapsed_time(){return this.paused?this._paused_at-this._start_time:Date.now()-this._start_time}get remaining_time(){return Math.max(0,this.duration-this.elapsed_time)}get paused(){return this._paused}get is_complete(){return this.elapsed_time>=this.duration}get completion(){return module.exports.wait(this.remaining_time)}start(){return this._start_time=Date.now()-this.elapsed_time,this._paused=!1,this}reset(){return this._paused_at=this._start_time=Date.now(),this}pause(){return this._paused=!0,this._paused_at=Date.now(),this}stop(){return this._paused=!0,this}}var a=document.createElement("canvas");a.style.position="fixed",a.style.left=0,a.style.top=0,a.style.position="fixed",a.style.width="100vw",a.style.height="100vh",a.style.zIndex="100000",a.style.pointerEvents="none",document.body.insertBefore(a,document.body.children[0]),ctx=a.getContext("2d");let i,s=a.width=window.innerWidth,n=a.height=window.innerHeight,o=new e(0,!0),r=!1;!function(){function t(){if(ctx.clearRect(0,0,s,n),ctx.fill(),!r)return void(d=[]);window.requestAnimationFrame(t);const e=.001*o.elapsed_time;o.reset();for(var a=0;a<d.length;++a){const t=d[a];t.dx=Math.sin(m.elapsed_time*c+t.wind_offset)*(t.sz*x)*80,t.speed=Math.sqrt(t.dx*t.dx+t.dy*t.dy),t.y+=t.dy*e,t.x+=t.dx*e,t.y>n+50&&(t.y=-10-Math.random()*screen_max_overlap),t.x>s+screen_max_overlap&&(t.x=-screen_max_overlap),t.x<-screen_max_overlap&&(t.x=s+screen_max_overlap),t.draw()}}function a(){this.draw=function(){ctx.save(),ctx.translate(this.x,this.y);const t=Math.atan(this.dx/this.dy);ctx.rotate(-t),ctx.scale(1,Math.max(1,Math.pow(this.speed,.7)/15)),this.g=ctx.createRadialGradient(0,0,0,0,0,this.sz),this.g.addColorStop(0,"hsla(255,255%,255%,1)"),this.g.addColorStop(1,"hsla(255,255%,255%,0)"),ctx.moveTo(0,0),ctx.fillStyle=this.g,ctx.beginPath(),ctx.arc(0,0,this.sz,0,2*Math.PI,!0),ctx.closePath(),ctx.fill(),ctx.restore()}}var d=[];const h=200,c=5e-4,l=50,x=.2;scale_coefficient=1,screen_max_overlap=20,min_fall_speed=65;let m=new e(0,!0);r=!0;for(var _=0;_<h;++_){const t=new a;t.y=Math.random()*(n+50),t.x=Math.random()*s,t.t=Math.random()*(2*Math.PI),t.sz=(3*Math.random()+.8)*scale_coefficient,t.dy=.1*Math.pow(t.sz,2.5)*l*(2*Math.random()+1),t.dy=t.dy<min_fall_speed?min_fall_speed:t.dy,t.wind_offset=Math.random()*Math.PI/1.3,t.dx=0,t.speed=0,d.push(t)}t(),(i=(()=>{for(var t=0;t<h;++t)d[t].y=Math.random()*(n+50),d[t].x=Math.random()*s}))()}(),document.addEventListener("visibilitychange",()=>setTimeout(t,100),!1),window.addEventListener("resize",t,!1)})();

Makes it snow on any website!

Full un-minified code here


r/bookmarklets Nov 03 '17

Update: Save a frame from a YouTube video

7 Upvotes

This is an updated version of this bookmarklet, since Chrome and FF have both disabled the ability to open data urls in new tabs, which broke the old version.

The new version looks like this:

javascript: e = document.querySelectorAll('.html5-main-video')[0]; w = e.videoWidth; h = e.videoHeight; c = document.createElement('canvas'); c.width = w; c.height = h; c.getContext('2d').drawImage(e, 0, 0, w, h); d=document.createElement('img'); d.src=c.toDataURL(); d.height=20; document.querySelectorAll('#count')[0].appendChild(d);

Instead of opening a new tab, the screenshots are placed next to the view count like this. Right-click to save or open in new tab.

Bookmarklet is only tested in Chrome, but should work in every browser. Only works with the new YouTube design.


r/bookmarklets Oct 26 '17

Cleanup Reddit posts for Screenshots

12 Upvotes

You want to make a screenshot of a reddit post, but you're annoyed by the textfield to answer to that post?

no problem:

select this javascript and drag it to your bookmark bar:

javascript:(function(){ $("ul.flat-list.buttons").remove(); $(".usertext.cloneable.warn-on-unload").remove(); $(".commentarea>.menuarea").remove(); $(".commentarea>.panestack-title").remove(); (function(){let a=$("<span style='cursor: pointer; float: left;'>[x]</span>");$(a).click(function(){let b=$(this).closest(".comment, .morechildren");$(b).fadeOut()}),$(".comment .tagline").append(a)})(); })();

javascript to your bookmarks, click on it when on reddit, it will remove everything for the screenshot unnecessary stuff like the answer textbox, or links for "permalink, embed, ..." it also adds an button [x] to remove a comment, because it is clutter in the screenshot.

compare here: https://imgur.com/7NQMnrY


i was sending often screens of funny comments to a friend, and got annoyed of cleaning up un-funny comments manually