Skip to content

Commit 9c94fff

Browse files
committed
First upload
1 parent 36b6eff commit 9c94fff

File tree

7 files changed

+163
-0
lines changed

7 files changed

+163
-0
lines changed

README.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#Lainpp
2+
3+
##Why Lainpp ?
4+
Because I am a C++ nerd.
5+
6+
##Why Chrome and not Firefox?
7+
Because I was using Windows with Chrome when I started this. I don't know how to make a Firefox Extension but it should be very simple to write the json or xml for Firefox. Please do it for me.
8+
9+
##Does it work?
10+
Barely. It has a lot of bugs but you can help if you want.
11+
12+
##Why a browser extension and not a contribution to Lainchan's Github repo?
13+
Because I didn't want to install all the dependencies just to test a few lines of Javascript and CSS.
14+
15+
##The icon is *super* ugly
16+
I know but I'm not sure if I'm able to use the Lainchan's favicon for this, ~~but I use that icon on my computer and it looks cute.~~
17+
18+
##TODO
19+
- Fix the lightbox, when you load an image for the first time it doesn't use the margin.
20+
- When you use the *Expand everything* button it also loads the videos.

css/style.css

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.multifile{
2+
width:100% !important;
3+
}
4+
.post-image{
5+
width:10vw !important;
6+
height:auto !important;
7+
}
8+
#lightbox{
9+
width:80vw;
10+
height:100vh;
11+
left:20vw;
12+
position:fixed;
13+
background:rgba(0,0,0,0.3);
14+
z-index:10000;
15+
}
16+
17+
#lightbox img{
18+
position: absolute;
19+
top:50%;
20+
left:50%;
21+
max-width:90%;
22+
max-height:90%;
23+
}
24+
table{
25+
position: fixed !important;
26+
bottom: 20px !important;
27+
right: -410px !important;
28+
background: #333333 !important;
29+
padding-left: 50px !important;
30+
transition: .2s;
31+
}
32+
table:hover{
33+
right: 0 !important;
34+
transition: .3s;
35+
}
36+
37+
.reply{
38+
width: 100% !important;
39+
}
40+
#quick-reply{
41+
width: 250px !important;
42+
}
43+
44+
#expand-img{
45+
color: #cccccc;
46+
text-decoration: none;
47+
cursor:pointer;
48+
}
49+
#expand-img:hover{
50+
color:#ffffff;
51+
}

img/icon128.png

4.8 KB
Loading

img/icon16.png

735 Bytes
Loading

img/icon48.png

1.44 KB
Loading

js/script.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
function lightbox(){
2+
var img = document.getElementsByClassName('post-image');
3+
var link, w, h;
4+
5+
for(var i = 0; i < img.length; i++){
6+
/*
7+
* When the pointer is on an image: load image into a lightbox,
8+
* read the width and height of the new image
9+
* and centers the image using those values
10+
*/
11+
img[i].addEventListener('mouseover', function(){
12+
link = this.parentElement.href;
13+
document.getElementById('thread').insertAdjacentHTML('afterbegin', '<div id="lightbox"><img id="lightbox-img" src="' + link + '"></div>');
14+
var lightboxImg = document.getElementById('lightbox-img');
15+
w = lightboxImg.width;
16+
h = lightboxImg.height;
17+
lightboxImg.setAttribute('style', 'margin: -' + h/2 + 'px 0px 0px -' + w/2 + 'px;');
18+
}, false);
19+
20+
/*
21+
* When pointer is out: Remove the lightbox from the DOM
22+
*/
23+
img[i].addEventListener('mouseout', function(){
24+
document.getElementById('lightbox').parentNode.removeChild(document.getElementById('lightbox'));
25+
}, false);
26+
27+
}
28+
29+
}
30+
31+
function expandIMG(){
32+
/*
33+
* It creates a button
34+
* in the bottom bar which can be used
35+
* to load all the original images in the thread
36+
*/
37+
var bottomBar = document.getElementsByClassName('threadlinks');
38+
for(var i = 0; i < bottomBar.length; i++){
39+
bottomBar[i].insertAdjacentHTML('afterbegin', '<span class="threadlink"><a id="expand-img">[ Expand images ] </a></span>');
40+
}
41+
42+
var botton = document.getElementById('expand-img');
43+
var img = document.getElementsByClassName('post-image');
44+
botton.addEventListener('click', function(){
45+
for(var i = 0; i < img.length; i++){
46+
img[i].click();
47+
}
48+
});
49+
}
50+
51+
window.addEventListener('load', function(){
52+
lightbox();
53+
expandIMG();
54+
});

manifest.json

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"manifest_version": 2,
3+
4+
"name": "Lain++",
5+
"version": "0.0.1",
6+
"description": "This extension gives Lainchan.org new functions",
7+
"version": "1.0",
8+
"author": "Akko",
9+
"homepage_url": "https://github.com/4k1k0/lainpp",
10+
11+
"browser_action": {
12+
"default_icon": "img/icon16.png",
13+
"default_title": "Lain++"
14+
},
15+
"icons": { "16": "img/icon16.png",
16+
"48": "img/icon48.png",
17+
"128": "img/icon128.png" },
18+
"content_scripts": [
19+
{
20+
"matches": [
21+
"https://lainchan.org/*",
22+
"https://lainchan.org/*/res/*.html"
23+
],
24+
"exclude_matches": [
25+
"https://lainchan.org/*/index.html",
26+
"https://lainchan.org/*/catalog.html"
27+
],
28+
"css": ["css/style.css"],
29+
"js": ["js/script.js"],
30+
"run_at": "document_end"
31+
}
32+
],
33+
"permissions": [
34+
"activeTab",
35+
"https://ajax.googleapis.com/"
36+
]
37+
}
38+

0 commit comments

Comments
 (0)