Skip to content

Instantly share code, notes, and snippets.

@sankage
Created November 26, 2012 02:04
Show Gist options
  • Save sankage/4146207 to your computer and use it in GitHub Desktop.
Save sankage/4146207 to your computer and use it in GitHub Desktop.
CodeTV - Mark watched videos bookmarklet

CodeTV video marker

This is a two piece bookmarklet to mark and highlight watched videos on CodeTV. It uses localStorage to keep track of the videos you have watched, so it has limited usefulness when viewing the videos from different computers.

Usage

  1. After watching a video, use the CodeTV::mark_watched bookmarklet to add that video's uri into localStorage.
  2. On the index page, use the CodeTV::highlight_watched bookmarklet to highlight all the videos that are in the localStorage bucket.
javascript:(function(){var div,filler,link,names,video,videos,_i,_j,_len,_ref,__slice=[].slice,__indexOf=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1};if(localStorage&&localStorage.getItem("watched_videos"))for(div='<div class="course-progress" data-width="100%" style="width: 100%;z-index: 0;"></div>',names=localStorage.getItem("watched_videos").split("|"),videos=$(".bucket-media"),_i=0,_len=videos.length;_len>_i;_i++)video=videos[_i],_ref=video.href.split("/"),filler=_ref.length>=2?__slice.call(_ref,0,_j=_ref.length-1):(_j=0,[]),link=_ref[_j++],__indexOf.call(names,link)>=0&&$(video).before(div)})();
javascript:(function(){var filler,link,names,_i,_ref,__slice=[].slice;localStorage&&(_ref=window.location.href.split("/"),filler=_ref.length>=2?__slice.call(_ref,0,_i=_ref.length-1):(_i=0,[]),link=_ref[_i++],names=localStorage.getItem("watched_videos")?localStorage.getItem("watched_videos"):"",names.length&&(names+="|"),names+=link,localStorage.setItem("watched_videos",names))})();
if localStorage and localStorage.getItem('watched_videos')
div = '<div class="course-progress" data-width="100%" style="width: 100%;z-index: 0;"></div>'
names = localStorage.getItem('watched_videos').split('|')
videos = $('.bucket-media')
for video in videos
[filler..., link] = video.href.split('/')
if link in names
$(video).before div
if localStorage
[filler..., link] = window.location.href.split('/')
names = if localStorage.getItem('watched_videos') then localStorage.getItem('watched_videos') else ''
names += '|' if names.length
names += link
localStorage.setItem('watched_videos', names)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment