From 96ec861bb5ed80dc122f94124775987ad7bea629 Mon Sep 17 00:00:00 2001 From: medyo Date: Sat, 23 Apr 2022 16:26:45 +0000 Subject: [PATCH 1/7] load carbonads from the server side --- public/carbon.js | 1 - public/manifest.json | 12 ++---- src/components/CarbonAd.js | 76 ++++++++++++++++++++++++++++++-------- 3 files changed, 64 insertions(+), 25 deletions(-) delete mode 100644 public/carbon.js diff --git a/public/carbon.js b/public/carbon.js deleted file mode 100644 index 25ed4088..00000000 --- a/public/carbon.js +++ /dev/null @@ -1 +0,0 @@ -var _carbonads={init:function(e,o){_carbon_where=null,e&&(_carbon_where=e);var a=this.getUrlVar("placement"),t=this.getUrlVar("cd")?this.getUrlVar("cd"):"srv.carbonads.net",r=this.getUrlVar("protocol")?this.getUrlVar("protocol")+":":"https:",n=this.getServe(o||this.getUrlVar("serve"),a),c=this.getUrlVar("_bsa_url_preview",window.location.href);if(c){var s=JSON.parse(decodeURIComponent(c));setTimeout(function(){_carbonads_go({ads:[Object.assign({},s,{zonekey:n,statlink:s.link.replace(/^(http:|https:)/gm,"")}),{}]})},0)}else{var i=document.createElement("script");i.id="_carbonads_projs",i.type="text/javascript",i.src=this._buildSrvUrl(r+"//"+t+"/ads/"+n+".json?segment=placement:"+a+"&callback=_carbonads_go"),document.getElementsByTagName("head")[0].appendChild(i)}},_buildSrvUrl:function(e){var o=this.getUrlVar("bsaforcebanner",window.location.href),a=this.getUrlVar("bsaignore",window.location.href),t=this.getUrlVar("bsaforwardedip",window.location.href);ignoretargeting=this.getUrlVar("bsaignoretargeting",window.location.href),o&&(e+="&forcebanner="+o),a&&(e+="&ignore="+a),ignoretargeting&&(e+="&ignoretargeting="+a),t&&(e+="&forwardedip="+t);var r="";try{r=decodeURIComponent(document.cookie)}catch(e){}var n=r.indexOf("_bsap_daycap="),c=r.indexOf("_bsap_lifecap=");if(n=n>=0?r.substring(n+12+1).split(";")[0].split(","):[],c=c>=0?r.substring(c+13+1).split(";")[0].split(","):[],n.length||c.length){for(var s=[],i=0;i/g,">").replace(/\//g,"/")}};function _carbonads_go(e){if(e){var o,a,t,r,n=e.ads[0],c=0|Math.round(Date.now()/1e4),s=_carbonads.getUrlVar("placement");_carbonads.getUrlVar("serve");if(void 0!==n.custom_css){var i=document.createElement("style");i.innerHTML=n.custom_css,document.getElementById("_carbonads_js").parentNode.insertBefore(i,document.getElementById("_carbonads_js"))}if(null!=n.html){var K=JSON.parse(n.html);n.image=K.image,n.statlink=K.statlink,n.description=K.description,n.pixel=K.pixel,n.click_redir=K.click_redir}if(!(_carbonads.nonempty(n.statlink)||_carbonads.nonempty(n.fallbackImage)&&_carbonads.nonempty(n.fallbackLink)&&_carbonads.nonempty(n.fallbackTitle)&&_carbonads.nonempty(n.fallbackZoneKey)||_carbonads.nonempty(n.fallbackImage)&&_carbonads.nonempty(n.fallbackLink)&&_carbonads.nonempty(n.fallbackTitle))){var l=_carbonads.nonempty(n.fallbackZoneKey)?n.fallbackZoneKey:"CK7DT53I";if(_carbonads.gotback===l)return;_carbonads.gotback=l;var m=document.createElement("script");return m.type="text/javascript",m.id="_carbonads_fallbackjs",m.src=_carbonads._buildSrvUrl("https://srv.carbonads.net/ads/"+l+".json?segment=placement:"+s+"&callback=_carbonads_go"),void("hide"!==n.fallbackTitle&&(document.getElementsByTagName("head")[0].appendChild(m),_carbonads.remove(document.getElementById("_carbonads_fallbackjs"))))}t=_carbonads.isset(n.logo)?n.logo:_carbonads.isset(n.smallImage)?n.smallImage:_carbonads.isset(n.image)?n.image:n.fallbackImage,o=_carbonads.isset(n.statlink)?n.statlink.split("?encredirect="):n.fallbackLink.replace(/^(http:|https:)/gm,""),r=_carbonads.isset(n.description)?n.description:_carbonads.isset(n.title)?n.title:n.fallbackTitle,bgcolor=_carbonads.isset(n.backgroundHoverColor)?n.backgroundHoverColor:null,a=(a=void 0!==o[1]&&_carbonads.isset(n.statlink)?o[0]+"?segment=placement:"+s+";&encredirect="+encodeURIComponent(o[1]):o[0].search("srv.buysellads.com")>0&&_carbonads.isset(n.statlink)?o[0]+"?segment=placement:"+s+";":Array.isArray(o)?o[0]:o).replace(/srv.buysellads.com/g,"srv.carbonads.net");var d=document.createElement("span");if(d.innerHTML='ads via Carbon'+_carbonads.htmlEncode(r)+"",_carbonads.isset(n.removecarbon)||(d.innerHTML+='ads via Carbon'),void 0!==n.pixel)for(var C=n.pixel.split("||"),I=0;I0?"carbonads_"+b.length:"carbonads",p.appendChild(d);var g=document.getElementById("_carbonads_js");null!=g&&(_carbonads.isset(_carbon_where)?_carbon_where.appendChild(p):g.parentNode.insertBefore(p,g.nextSibling));for(var h=document.querySelectorAll(".carbon-img > img"),u=0;u=0?t.substring(r+e.length+1).split(";")[0]+"%2C":"",c=new Date;c.setTime(36e5*a+c),o=(o=n+o).substring(0,2048),document.cookie=e+"="+o+"; expires="+c.toGMTString()+"; SameSite=Lax; path=/"};a&&(t("_bsap_daycap",e,1),t("_bsap_lifecap",e,365))}; diff --git a/public/manifest.json b/public/manifest.json index a88aa159..523de360 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,26 +1,22 @@ { "name": "Hackertab.dev", "description": "The Developer’s Homepage", - "version": "1.12.1", + "version": "1.12.2", "manifest_version": 2, "chrome_url_overrides": { "newtab": "index.html" }, "background": { - "scripts": [ - "background.js" - ] + "scripts": ["background.js"] }, - "permissions": [ - "https://*.hackertab.dev/*" - ], + "permissions": ["https://*.hackertab.dev/*"], "icons": { "16": "/logos/logo16.png", "32": "/logos/logo32.png", "48": "/logos/logo48.png", "128": "/logos/logo128.png" }, - "content_security_policy": "script-src 'self' https://*.carbonads.com https://*.buysellads.net https://*.buysellads.com https://*.servedby-buysellads.com https://*.carbonads.net; object-src 'self'", + "content_security_policy": "script-src 'self' object-src 'self'", "applications": { "gecko": { "id": "{f8793186-e9da-4332-aa1e-dc3d9f7bb04c}" diff --git a/src/components/CarbonAd.js b/src/components/CarbonAd.js index 89ae7d7a..41785728 100644 --- a/src/components/CarbonAd.js +++ b/src/components/CarbonAd.js @@ -1,20 +1,64 @@ -import React, { Component } from 'react'; -import './CarbonAd.css'; +import axios from 'axios' +import React, { useEffect, useState } from 'react' +import './CarbonAd.css' -class CarbonAd extends Component { - componentDidMount() { - const carbon_wrapper = document.querySelector('.carbon-ad-wrapper') - const script = document.createElement('script') - script.src = process.env.PUBLIC_URL + '/carbon.js?serve=CESDP23I&placement=hackertabdev' - script.async = true - script.id = '_carbonads_js' +export default function CarbonAd() { + const [ad, setAd] = useState() + const packageFile = require('../../package.json') - carbon_wrapper.appendChild(script) - } + useEffect(() => { + const setup = async () => { + const userAgent = new URLSearchParams(navigator.userAgent).toString() + var baseUrl = process.env.NODE_ENV === 'production' ? packageFile.proxy : '' + const request = await axios.get(`${baseUrl}/monetization/?useragent=${userAgent}`) + if (request.data) { + setAd(request.data.ads[0]) + } + } + setup() + }, []) - render() { - return
- } -} + return ( +
+ {ad && ( +
+ + + + ads via Carbon + + + + {ad.description} + + -export default CarbonAd; + + ads via Carbon + + +
+ )} +
+ ) +} From a598162bcda36193b62085adecda34760a51ba1d Mon Sep 17 00:00:00 2001 From: medyo Date: Sat, 23 Apr 2022 17:32:05 +0000 Subject: [PATCH 2/7] hide img alt --- src/components/CarbonAd.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/CarbonAd.js b/src/components/CarbonAd.js index 41785728..b3139f81 100644 --- a/src/components/CarbonAd.js +++ b/src/components/CarbonAd.js @@ -32,7 +32,6 @@ export default function CarbonAd() { title={ad.company + ' ' + ad.companyTagline}> ads via Carbon Date: Sat, 23 Apr 2022 17:41:11 +0000 Subject: [PATCH 3/7] bump version --- public/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/manifest.json b/public/manifest.json index 523de360..7886b3e5 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,7 +1,7 @@ { "name": "Hackertab.dev", "description": "The Developer’s Homepage", - "version": "1.12.2", + "version": "1.12.3", "manifest_version": 2, "chrome_url_overrides": { "newtab": "index.html" From 50b671c5e484271d7bb5dec96b07d349b6cb205a Mon Sep 17 00:00:00 2001 From: medyo Date: Sun, 24 Apr 2022 18:53:53 +0000 Subject: [PATCH 4/7] prepend https --- public/manifest.json | 2 +- src/components/CarbonAd.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/public/manifest.json b/public/manifest.json index 7886b3e5..6b565a74 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,7 +1,7 @@ { "name": "Hackertab.dev", "description": "The Developer’s Homepage", - "version": "1.12.3", + "version": "1.12.4", "manifest_version": 2, "chrome_url_overrides": { "newtab": "index.html" diff --git a/src/components/CarbonAd.js b/src/components/CarbonAd.js index b3139f81..bb4ccb8f 100644 --- a/src/components/CarbonAd.js +++ b/src/components/CarbonAd.js @@ -18,6 +18,14 @@ export default function CarbonAd() { setup() }, []) + const prependHTTP = (url) => { + url = decodeURIComponent(url) + if (!/^(?:f|ht)tps?\:\/\//.test(url)) { + url = 'https://' + url + } + return url + } + return (
{ad && ( @@ -25,7 +33,7 @@ export default function CarbonAd() { From e2c48c7cdd7e0396070cbf6a2d0c5846dce85901 Mon Sep 17 00:00:00 2001 From: medyo Date: Thu, 5 May 2022 12:38:42 +0000 Subject: [PATCH 5/7] remove stackoverflow jobs (disconnected service) --- README.md | 5 +- src/Constants.js | 10 -- src/bookmark/BookmarksSidebar.js | 9 +- src/cards/JobsCard.js | 107 ---------------------- src/configuration/AppWrapper.js | 1 + src/configuration/ConfigurationContext.js | 1 - src/services/stackoverflow.js | 11 --- src/utils/Analytics.js | 8 +- 8 files changed, 8 insertions(+), 144 deletions(-) delete mode 100644 src/cards/JobsCard.js delete mode 100644 src/services/stackoverflow.js diff --git a/README.md b/README.md index 4620dbf7..5c23f416 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Chrome Web Store Rating](https://img.shields.io/chrome-web-store/stars/ocoipcahhaedjhnpoanfflhbdcpmalmp.svg?colorB=%234FC828&label=rating&style=flat)](https://chrome.google.com/webstore/detail/hackertabdev/ocoipcahhaedjhnpoanfflhbdcpmalmp/reviews) # Hackertab.dev — The Developer’s Homepage -Hackertab turns your New Tab page into a geeky one that keeps you as a developer updated with the latest tech news, libs, jobs and events. +Hackertab turns your New Tab page into a geeky one that keeps you as a developer updated with the latest tech news, libs and events. Hackertab.dev @@ -16,7 +16,7 @@ Hackertab saves you time and gives you a daily dose of tech news you need to kno 👉 [now.hackertab.dev](https://now.hackertab.dev) #### How? -Hackertab brings the latest news, libraries, tech events, jobs... related to your profile (back-end, mobile, full stack, data scientist...) +Hackertab brings the latest news, libraries, tech events... related to your profile (back-end, mobile, full stack, data scientist...) and visualize them in a proper way so you don't have to waste time jumping between different data sources. @@ -43,7 +43,6 @@ and visualize them in a proper way so you don't have to waste time jumping betwe - DevTo - Hashnode - Lobsters -- Stackoverflow Jobs - Confs.tech - Product Hunt - Reddit diff --git a/src/Constants.js b/src/Constants.js index 064dd256..8e58c864 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -2,7 +2,6 @@ import React from 'react' import HNCard from './cards/HNCard' import DevToCard from './cards/DevToCard' import ConferencesCard from './cards/ConferencesCard' -import JobsCard from './cards/JobsCard' import ReposCard from './cards/ReposCard' import ProductHuntCard from './cards/ProductHuntCard' import RedditCard from './cards/RedditCard' @@ -14,13 +13,11 @@ import { SiYcombinator } from 'react-icons/si' import { FaDev } from 'react-icons/fa' import { SiProducthunt } from 'react-icons/si' import { FaReddit } from 'react-icons/fa' -import { SiStackoverflow } from 'react-icons/si' import { HiTicket } from 'react-icons/hi' import HashNodeIcon from './static/icon_hashnode.png' import LobstersIcon from './static/icon_lobsters.png' import { FaFreeCodeCamp } from 'react-icons/fa' - const APP = { name: 'Hackertab.dev', slogan: '— Stay updated with the new technology and trends', @@ -47,13 +44,6 @@ export const SUPPORTED_CARDS = [ label: 'Github repositories', component: ReposCard, }, - { - value: 'jobs', - icon: , - analyticsTag: 'jobs', - label: 'Featured jobs', - component: JobsCard, - }, { value: 'hackernews', icon: , diff --git a/src/bookmark/BookmarksSidebar.js b/src/bookmark/BookmarksSidebar.js index 74f989f0..140e5b04 100644 --- a/src/bookmark/BookmarksSidebar.js +++ b/src/bookmark/BookmarksSidebar.js @@ -3,7 +3,7 @@ import './Sidebar.css'; import { VscChromeClose } from 'react-icons/vsc'; import { TiDelete } from 'react-icons/ti'; import { HiTicket } from 'react-icons/hi'; -import { SiGithub, SiReddit, SiStackoverflow, SiProducthunt, SiYcombinator } from 'react-icons/si'; +import { SiGithub, SiReddit, SiProducthunt, SiYcombinator } from 'react-icons/si' import { ProSidebar, Menu, MenuItem, SubMenu, SidebarHeader, SidebarContent } from 'react-pro-sidebar'; import 'react-pro-sidebar/dist/css/styles.css'; import PreferencesContext from '../preferences/PreferencesContext'; @@ -80,13 +80,6 @@ function BookmarksSidebar({ showSidebar, onClose }) { - } - suffix={{jobsBookmarks.length}} - > - { - jobsBookmarks.map((bm, index) => ()) - } - } suffix={{conferencesBookmarks.length}} > diff --git a/src/cards/JobsCard.js b/src/cards/JobsCard.js deleted file mode 100644 index 6ffb2a82..00000000 --- a/src/cards/JobsCard.js +++ /dev/null @@ -1,107 +0,0 @@ - -import React, { useEffect, useState, useContext } from 'react' -import { SiStackoverflow } from 'react-icons/si'; -import { VscBriefcase } from 'react-icons/vsc'; -import { MdAccessTime } from "react-icons/md" -import CardComponent from "../components/CardComponent"; -import ListComponent from "../components/ListComponent"; -import stackoverflowApi from '../services/stackoverflow'; -import { format } from 'timeago.js'; -import PreferencesContext from '../preferences/PreferencesContext' -import CardLink from "../components/CardLink" -import CardItemWithActions from '../components/CardItemWithActions' -import ColoredLanguagesBadge from "../components/ColoredLanguagesBadge" - - -const JobItem = ({ item, index, analyticsTag }) => { - - const { listingMode } = useContext(PreferencesContext) - - return ( - - - {item.title} - - { listingMode === "normal" ? - <> -

- {format(item.date)} - {item.location} -

- -

- -

- : -

- {item.location} -

- } - - )} - /> - ) -} - -function JobsCard({ analyticsTag, label, icon, withAds }) { - const preferences = useContext(PreferencesContext) - - const { userSelectedTags } = preferences - - const [refresh, setRefresh] = useState(true) - - const fetchJobs = async () => { - const promises = userSelectedTags.map((tag) => { - if (tag['stackoverflowValues']) { - return stackoverflowApi.getJobs(tag['stackoverflowValues'][0]) - } - return [] - }) - const results = await Promise.allSettled(promises) - - return results - .map((res, index) => { - let value = res.value - if (res.status === 'rejected') { - value = [] - } - return value.map((c) => ({ - ...c, - tag: userSelectedTags[index], - date: new Date(c.isoDate), - })) - }) - .flat() - .sort((a, b) => b.date - a.date) - } - - useEffect(() => { - setRefresh(!refresh) - }, [userSelectedTags]) - - const renderItem = (item, index) => ( - - ) - - return ( - {icon}
} - link="https://stackoverflow.com/jobs" - title={label}> - - - ) -} - -export default JobsCard \ No newline at end of file diff --git a/src/configuration/AppWrapper.js b/src/configuration/AppWrapper.js index 30c7208c..c0c849e0 100644 --- a/src/configuration/AppWrapper.js +++ b/src/configuration/AppWrapper.js @@ -34,6 +34,7 @@ export default function AppWrapper({ children }) { userSelectedTags: configuration.supportedTags.filter((tag) => preferences.userSelectedTags.includes(tag.value) ), + cards: preferences.cards.filter((card) => card.name != 'stackoverflow'), } return { ...initialState, diff --git a/src/configuration/ConfigurationContext.js b/src/configuration/ConfigurationContext.js index 78ecafa6..29024812 100644 --- a/src/configuration/ConfigurationContext.js +++ b/src/configuration/ConfigurationContext.js @@ -7,7 +7,6 @@ const ConfigurationContext = React.createContext({ label: 'Javascript', githubValues: ['javascript'], confsValues: ['javascript'], - stackoverflowValues: ['javascript'], devtoValues: ['javascript'], hashnodeValues: ['javascript'], }, diff --git a/src/services/stackoverflow.js b/src/services/stackoverflow.js deleted file mode 100644 index 976b0fc3..00000000 --- a/src/services/stackoverflow.js +++ /dev/null @@ -1,11 +0,0 @@ -import cachedRequest from './cachedRequest'; - -const getJobs = async (tag) => { - const url = `/data/stackoverflow/${tag}.json`; - const data = await cachedRequest(url); - return data -} - -export default { - getJobs: getJobs, -} diff --git a/src/utils/Analytics.js b/src/utils/Analytics.js index de546cdf..2359279f 100644 --- a/src/utils/Analytics.js +++ b/src/utils/Analytics.js @@ -90,8 +90,8 @@ const trackException = (exceptionMessage, fatal) => { console.log('Analytics debug payload', payload.toString()) return } - - navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString()) + // Disabled + //navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString()) } const getResolution = () => { const realWidth = window.screen.width @@ -133,8 +133,8 @@ const trackEvent = (category, action, label) => { console.log('Analytics debug payload', payload.toString()) return } - - navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString()) + // Disabled + //navigator.sendBeacon('https://www.google-analytics.com/collect', payload.toString()) } const getRandomUserId = () => { From be8d7190481afa9dd4fe50421927a6d93e1ebdd8 Mon Sep 17 00:00:00 2001 From: medyo Date: Thu, 5 May 2022 16:27:30 +0000 Subject: [PATCH 6/7] refactor the base api path --- src/components/CarbonAd.js | 5 ++--- src/services/cachedRequest.js | 7 +++---- src/utils/DataUtils.js | 6 ++++++ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/CarbonAd.js b/src/components/CarbonAd.js index bb4ccb8f..de7997af 100644 --- a/src/components/CarbonAd.js +++ b/src/components/CarbonAd.js @@ -1,16 +1,15 @@ import axios from 'axios' import React, { useEffect, useState } from 'react' import './CarbonAd.css' +import { getBaseApi } from '../utils/DataUtils' export default function CarbonAd() { const [ad, setAd] = useState() - const packageFile = require('../../package.json') useEffect(() => { const setup = async () => { const userAgent = new URLSearchParams(navigator.userAgent).toString() - var baseUrl = process.env.NODE_ENV === 'production' ? packageFile.proxy : '' - const request = await axios.get(`${baseUrl}/monetization/?useragent=${userAgent}`) + const request = await axios.get(`${getBaseApi('')}/monetization/?useragent=${userAgent}`) if (request.data) { setAd(request.data.ads[0]) } diff --git a/src/services/cachedRequest.js b/src/services/cachedRequest.js index 68ae70c4..91d56a21 100644 --- a/src/services/cachedRequest.js +++ b/src/services/cachedRequest.js @@ -1,11 +1,10 @@ import axios from 'axios'; import AppStorage from "./localStorage"; - -var packageFile = require("../../package.json"); +import { getBaseApi } from '../utils/DataUtils' const axiosInstance = axios.create({ - baseURL: process.env.NODE_ENV === "production" ? packageFile.proxy : null, -}); + baseURL: getBaseApi(null), +}) const isWebVersion = !!+process.env.REACT_APP_WEB_BUILD const cachedRequest = async (url) => { diff --git a/src/utils/DataUtils.js b/src/utils/DataUtils.js index f4c9c9c9..d7ea61fc 100644 --- a/src/utils/DataUtils.js +++ b/src/utils/DataUtils.js @@ -1,3 +1,5 @@ +const packageFile = require('../../package.json') + export const mergeMultipleDataSources = async (promises, maxCount) => { let promisesRequests = await Promise.allSettled(promises) let promisesValues = promisesRequests @@ -20,3 +22,7 @@ export const mergeMultipleDataSources = async (promises, maxCount) => { } return data } + +export const getBaseApi = (fallback) => { + return process.env.NODE_ENV === 'production' ? packageFile.proxy : fallback +} From fd131f4e3134579932c261fe5d6fc1d07361cf3e Mon Sep 17 00:00:00 2001 From: medyo Date: Fri, 6 May 2022 11:51:35 +0000 Subject: [PATCH 7/7] bump app version to 1.13.0 --- public/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/manifest.json b/public/manifest.json index 6b565a74..d83fd3f8 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,7 +1,7 @@ { "name": "Hackertab.dev", "description": "The Developer’s Homepage", - "version": "1.12.4", + "version": "1.13.0", "manifest_version": 2, "chrome_url_overrides": { "newtab": "index.html"