diff --git a/README.md b/README.md index f13b668..7a7e891 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ -# lorpic +# LORPic: Плагин для браузеров Mozilla Firefox и Chrome/Chromium +![screenshot](https://git.lnx4.ru/lnx4/lorpic/screenshot.png) + +Подробнее: \ No newline at end of file diff --git a/chromium-lorpic/128-icon.png b/chromium-lorpic/128-icon.png new file mode 100644 index 0000000..ee2bd02 Binary files /dev/null and b/chromium-lorpic/128-icon.png differ diff --git a/chromium-lorpic/32-icon.png b/chromium-lorpic/32-icon.png new file mode 100644 index 0000000..26fa945 Binary files /dev/null and b/chromium-lorpic/32-icon.png differ diff --git a/chromium-lorpic/64-icon.png b/chromium-lorpic/64-icon.png new file mode 100644 index 0000000..bce2427 Binary files /dev/null and b/chromium-lorpic/64-icon.png differ diff --git a/chromium-lorpic/app.js b/chromium-lorpic/app.js new file mode 100755 index 0000000..8e80286 --- /dev/null +++ b/chromium-lorpic/app.js @@ -0,0 +1,28 @@ +(function() { + // Code Here + const formats = ['jpeg', 'jpg', 'png'] + let links = document.querySelectorAll('a[href]:not([itemprop])'); + + links.forEach(function(link){ + let url = link.getAttribute('href'); + let ext = _getUrlExt(url); + + if(formats.includes(ext)){ + let content = link.textContent; + + if(content != 'Просмотр'){ + let image = document.createElement("img"); + + image.setAttribute('class', 'lorpic'); + image.setAttribute('src', url); + //link.replaceWith(image); + link.appendChild(image); + link.setAttribute('target', '_blank'); + } + } + }); + + function _getUrlExt(url){ + return url.split('.').pop(); + } +})(); diff --git a/chromium-lorpic/manifest.json b/chromium-lorpic/manifest.json new file mode 100755 index 0000000..2c8d7d0 --- /dev/null +++ b/chromium-lorpic/manifest.json @@ -0,0 +1,21 @@ +{ + "manifest_version": 3, + "name": "LORPic", + "version": "1.0", + "description": "Плагин отображения картинок для LOR", + "icons": { + "32": "32-icon.png", + "64": "64-icon.png", + "128": "128-icon.png" + }, + "content_scripts": [ + { + "matches": [ "*://*.linux.org.ru/gallery/*/*", + "*://*.linux.org.ru/articles/*/*", + "*://*.linux.org.ru/news/*/*", + "*://*.linux.org.ru/forum/*/*" ], + "js": [ "app.js" ], + "css": [ "style.css" ] + } + ] +} diff --git a/chromium-lorpic/style.css b/chromium-lorpic/style.css new file mode 100755 index 0000000..69ed968 --- /dev/null +++ b/chromium-lorpic/style.css @@ -0,0 +1,5 @@ +a img.lorpic { + display: block; + max-width: 33%; + height: auto; +} diff --git a/firefox-lorpic/128-icon.png b/firefox-lorpic/128-icon.png new file mode 100644 index 0000000..ee2bd02 Binary files /dev/null and b/firefox-lorpic/128-icon.png differ diff --git a/firefox-lorpic/32-icon.png b/firefox-lorpic/32-icon.png new file mode 100644 index 0000000..26fa945 Binary files /dev/null and b/firefox-lorpic/32-icon.png differ diff --git a/firefox-lorpic/64-icon.png b/firefox-lorpic/64-icon.png new file mode 100644 index 0000000..bce2427 Binary files /dev/null and b/firefox-lorpic/64-icon.png differ diff --git a/firefox-lorpic/app.js b/firefox-lorpic/app.js new file mode 100755 index 0000000..8e80286 --- /dev/null +++ b/firefox-lorpic/app.js @@ -0,0 +1,28 @@ +(function() { + // Code Here + const formats = ['jpeg', 'jpg', 'png'] + let links = document.querySelectorAll('a[href]:not([itemprop])'); + + links.forEach(function(link){ + let url = link.getAttribute('href'); + let ext = _getUrlExt(url); + + if(formats.includes(ext)){ + let content = link.textContent; + + if(content != 'Просмотр'){ + let image = document.createElement("img"); + + image.setAttribute('class', 'lorpic'); + image.setAttribute('src', url); + //link.replaceWith(image); + link.appendChild(image); + link.setAttribute('target', '_blank'); + } + } + }); + + function _getUrlExt(url){ + return url.split('.').pop(); + } +})(); diff --git a/firefox-lorpic/manifest.json b/firefox-lorpic/manifest.json new file mode 100755 index 0000000..6c6a6a1 --- /dev/null +++ b/firefox-lorpic/manifest.json @@ -0,0 +1,21 @@ +{ + "manifest_version": 2, + "name": "LORPic", + "version": "1.0", + "description": "Плагин отображения картинок для LOR", + "icons": { + "32": "32-icon.png", + "64": "64-icon.png", + "128": "128-icon.png" + }, + "content_scripts": [ + { + "matches": [ "*://*.linux.org.ru/gallery/*/*", + "*://*.linux.org.ru/articles/*/*", + "*://*.linux.org.ru/news/*/*", + "*://*.linux.org.ru/forum/*/*" ], + "js": [ "app.js" ], + "css": [ "style.css" ] + } + ] +} diff --git a/firefox-lorpic/style.css b/firefox-lorpic/style.css new file mode 100755 index 0000000..69ed968 --- /dev/null +++ b/firefox-lorpic/style.css @@ -0,0 +1,5 @@ +a img.lorpic { + display: block; + max-width: 33%; + height: auto; +} diff --git a/screenshot.png b/screenshot.png new file mode 100644 index 0000000..0dedb28 Binary files /dev/null and b/screenshot.png differ