Created
July 18, 2017 00:47
-
-
Save theand/41c71d909848744a405e03886d732ac0 to your computer and use it in GitHub Desktop.
https://www.pycon.kr/2017/program/schedule/ 프로그램 표 선택 내용을 브라우저에 기억시켜두는 유저스크립트
This file contains 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 PyconKR Program Select | |
// @namespace http://127.0.0.1 | |
// @description User Script for PyconKR Program Select | |
// @author Heesang Chae | |
// @include https://www.pycon.kr/2017/program/schedule/* | |
// @require https://cdn.jsdelivr.net/gh/marcuswestin/store.js@v2.0.1/dist/store.everything.min.js | |
// @version 2017.07.17 | |
// @grant none | |
// ==/UserScript== | |
var userscript = function () { | |
console.log("init : Pycon Program Select userscript - " + document.location.toString()); | |
try { | |
var tdcells = $("div.timetable-wide table tbody tr td.cell").not(".cell-span"); | |
var selected = store.get('selectedCell') || []; | |
const highlight = 'bg-success'; | |
tdcells.each((i, e) => { | |
$(e).data("index", i); | |
$(e).on('click', () => { | |
var i = $(e).data('index'); | |
$(e).toggleClass(highlight); | |
if ($(e).hasClass(highlight)) { | |
selected.push(i); | |
} else { | |
selected = selected.filter(e => e !== i); | |
} | |
store.set('selectedCell', selected); | |
}); | |
if (selected.indexOf(i) !== -1) { | |
$(e).toggleClass(highlight); | |
} | |
}); | |
} catch (err) { | |
console.error("UserScript : " + err.toString()); | |
} | |
}; | |
var el = document.createElement('script'); | |
el.type = 'text/javascript'; | |
el.text = '(' + userscript + ')();'; | |
document.head.appendChild(el); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment