From 952690a756b76e63edf4bc358cdaf557f123349a Mon Sep 17 00:00:00 2001 From: PoTTii Date: Thu, 8 Apr 2021 16:53:01 +0200 Subject: [PATCH] fix rep0st, add probability, release v.1.7.0 --- package.json | 2 +- src/module/Rep0st.js | 20 +++++++++++++++----- src/style/rep0st.less | 13 +++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 91a1335..48e08c4 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "TamperMonkey", "pr0gramm" ], - "version": "1.6.1", + "version": "1.7.0", "license": "GPL-3.0", "dependencies": { "chart.js": "^2.9.3", diff --git a/src/module/Rep0st.js b/src/module/Rep0st.js index 363cc57..7e56d49 100644 --- a/src/module/Rep0st.js +++ b/src/module/Rep0st.js @@ -96,16 +96,23 @@ export default class Rep0st { this.visible = true; this.loader.remove(); result.html($(res.responseText)); - const images = result.find('.result-list a'); + const images = result.find('.search-results a'); let currentPostId = this.getCurrentPostId(); for (let i = 1; i < images.length; i++) { let postId = parseInt(images[i].href.replace('pr0gramm', '').replace(/\D/g,'')); if(currentPostId !== postId) { + let childrenList = images[i].children[0]; + + let postUrl = images[i].href; + let probability = childrenList.children[0].innerHTML; + let imgSrc = childrenList.children[1].src; + output.push({ - url: images[i].href, - img: images[i].style.backgroundImage.match(/\(([^)]+)\)/)[1] + url: postUrl, + img: imgSrc, + probability: probability, }); } } @@ -126,8 +133,11 @@ export default class Rep0st { bar = bar.find('.simplebar-content'); for (let i = 0; i < urls.length; i++) { - let container = bar.append($(``)); - let comment = container.find(`img[src=${urls[i].img}] + span`)[0]; + let probabilityContainer = `
${urls[i].probability}
`; + + let container = bar.append($(`${probabilityContainer}`)); + + let comment = container.find(`img[src='${urls[i].img}'] + span`)[0]; comment.addEventListener('click', (e) => { e.preventDefault(); diff --git a/src/style/rep0st.less b/src/style/rep0st.less index 76380c6..e781a81 100644 --- a/src/style/rep0st.less +++ b/src/style/rep0st.less @@ -82,3 +82,16 @@ margin-top: 30px; width: 15vw; } + +.probability { + position: absolute; + top: 5px; + right: 5px; + font-weight: bold; + color: red; + + &:hover { + background-color: black; + padding: 0 4px; + } +} \ No newline at end of file