-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbigpicture.navi.user.js
58 lines (51 loc) · 1.93 KB
/
bigpicture.navi.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ==UserScript==
// @name BigPicture stuff
// @namespace q.alexander.bigpicture.navi
// @include http://www.bostonglobe.com/news/bigpicture/*
// @include https://www.bostonglobe.com/news/bigpicture/*
// @version 2.1
// @grant none
// @require https://code.jquery.com/jquery-3.7.1.min.js
// ==/UserScript==
(function(){
var set_body_height = function () { jQuery('body').css('height', jQuery(window).height()); };
jQuery('head').append('<style type="text/css">article.pcaption {opacity: 0} article.pcaption:hover {opacity: 0.9}</style>');
jQuery('div#contain').css('height', '100%');
jQuery('div#container').css('height', '100%');
jQuery('div#container>section').css('height', '100%');
jQuery('img').css('max-height', '100%');
jQuery('div.mfp-wrap').remove();
jQuery('div.mfp-bg').click();
jQuery('header.bg-header').remove();
jQuery('div#container').nextAll().remove();
jQuery('article.pcaption').each(function(){
jQuery(this).appendTo(jQuery(this).prev());
jQuery(this).css('position', 'relative');
jQuery(this).css('bottom', '100%');
jQuery(this).css('background-color', '#000000');
});
jQuery('div.photo').css('height', '100%');
jQuery(window).bind('resize', set_body_height);
set_body_height();
// navigation
var imgs = jQuery('div.photo');
var idx = -1;
jQuery(document).keypress(function(e){
var doit=false;
if (e.which == 106 || e.which == 37) { //next
idx++;
if (idx >= imgs.length) idx = 0;
doit = true;
} else if (e.which == 107 || e.which == 39) { //prev
idx--;
if (idx < 0) idx = imgs.length;
doit = true;
}
if (doit) {
console.log('scrolling to ' + idx);
jQuery('html, body').animate({
scrollTop: jQuery(imgs[idx]).offset().top
}, 500);
}
});
})();