|
1 | 1 | // ==UserScript== |
2 | | -// @version 2.4.26199.27938 |
| 2 | +// @version 2.4.26202.21213 |
3 | 3 | // @author Write |
4 | 4 | // @name OphirofoxScript |
5 | 5 | // @grant GM.getValue |
|
2657 | 2657 | if ("https://www.standaard.be/*".includes(hostname)) { |
2658 | 2658 |
|
2659 | 2659 | window.addEventListener("load", function(event) { |
| 2660 | + let buttonAdded = false; |
| 2661 | + const article_title = document.querySelector('header[data-testid="article-header"] h1'); |
| 2662 | + |
2660 | 2663 | function extractKeywords() { |
2661 | | - return document.querySelector("header h1").textContent; |
| 2664 | + return article_title.textContent; |
2662 | 2665 | } |
2663 | 2666 |
|
2664 | | - let buttonAdded = false; |
2665 | | - |
2666 | 2667 | async function createLink(elt) { |
2667 | 2668 | if (elt && buttonAdded == false) { |
2668 | 2669 | const a = await ophirofoxEuropresseLink(extractKeywords()); |
2669 | 2670 | elt.after(a); |
| 2671 | + console.log(elt); |
| 2672 | + if (elt !== article_title) { |
| 2673 | + //second link is in shadow dom context -> no access to stylesheet |
| 2674 | + a.style.display = "block" |
| 2675 | + a.style.width = "35%"; |
| 2676 | + a.style.margin = "0.5rem auto"; |
| 2677 | + a.style.padding = "0.5rem 0"; |
| 2678 | + a.style.borderRadius = "0.3rem"; |
| 2679 | + a.style.backgroundColor = "#ffc700"; |
| 2680 | + a.style.color = "#000"; |
| 2681 | + a.style.textDecoration = "none"; |
| 2682 | + a.style.textAlign = "center"; |
| 2683 | + } |
2670 | 2684 | } |
2671 | 2685 | } |
2672 | 2686 |
|
2673 | 2687 | async function onLoad() { |
2674 | | - // Lien Europresse dans le corps de l'article |
2675 | | - const paywall = document.querySelector('[data-cj-root="subscription-wall"]'); |
2676 | | - const article_title = document.querySelector('header h1'); |
2677 | | - |
2678 | | - if (paywall) { |
2679 | | - createLink(article_title); |
2680 | | - } |
2681 | | - |
2682 | | - // Lien Europresse dans la modale, au chargement |
2683 | 2688 | const callback = (mutationList, observer) => { |
2684 | 2689 | for (const mutation of mutationList) { |
2685 | 2690 | if (mutation.type === 'childList') { |
2686 | 2691 | for (let node of mutation.addedNodes) { |
2687 | | - const paywall_modal = document.querySelector('.cj-root'); |
| 2692 | + const paywall_modal = document.querySelector('.PSAPAG_root'); |
2688 | 2693 | if (paywall_modal) { |
2689 | | - const subscriptionForm = document.querySelector('[data-current-screen="CtaAuthPaying"] form'); |
2690 | | - createLink(subscriptionForm); |
| 2694 | + ; |
| 2695 | + const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot; |
| 2696 | + const modal_content = shadow_content.firstChild.lastChild; |
| 2697 | + createLink(article_title); |
| 2698 | + createLink(modal_content); |
| 2699 | + |
2691 | 2700 | buttonAdded = true; |
2692 | | - subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link'); |
2693 | 2701 | observer.disconnect(); |
2694 | 2702 | } |
2695 | 2703 | } |
|
2718 | 2726 | text-align: center; |
2719 | 2727 | text-decoration: none !important; |
2720 | 2728 | } |
2721 | | - |
2722 | | - .ophirofox-modal-link { |
2723 | | - display: block; |
2724 | | - margin-top: 0; |
2725 | | - padding: 0.5rem; |
2726 | | - border-radius: 0; |
2727 | | - } |
2728 | 2729 | `); |
2729 | 2730 | } |
2730 | 2731 |
|
|
2878 | 2879 | if ("https://www.gva.be/*".includes(hostname)) { |
2879 | 2880 |
|
2880 | 2881 | window.addEventListener("load", function(event) { |
| 2882 | + let buttonAdded = false; |
| 2883 | + const article_title = document.querySelector('header[data-testid="article-header"] h1'); |
| 2884 | + |
2881 | 2885 | function extractKeywords() { |
2882 | | - return document.querySelector("header h1").textContent; |
| 2886 | + return article_title.textContent; |
2883 | 2887 | } |
2884 | 2888 |
|
2885 | | - let buttonAdded = false; |
2886 | | - |
2887 | 2889 | async function createLink(elt) { |
2888 | 2890 | if (elt && buttonAdded == false) { |
2889 | 2891 | const a = await ophirofoxEuropresseLink(extractKeywords()); |
2890 | 2892 | elt.after(a); |
| 2893 | + console.log(elt); |
| 2894 | + if (elt !== article_title) { |
| 2895 | + //second link is in shadow dom context -> no access to stylesheet |
| 2896 | + a.style.display = "block" |
| 2897 | + a.style.width = "35%"; |
| 2898 | + a.style.margin = "0.5rem auto"; |
| 2899 | + a.style.padding = "0.5rem 0"; |
| 2900 | + a.style.borderRadius = "0.3rem"; |
| 2901 | + a.style.backgroundColor = "#ffc700"; |
| 2902 | + a.style.color = "#000"; |
| 2903 | + a.style.textDecoration = "none"; |
| 2904 | + a.style.textAlign = "center"; |
| 2905 | + } |
2891 | 2906 | } |
2892 | 2907 | } |
2893 | 2908 |
|
2894 | 2909 | async function onLoad() { |
2895 | | - // Lien Europresse dans le corps de l'article |
2896 | | - const paywall = document.querySelector('[data-cj-root="subscription-wall"]'); |
2897 | | - const article_title = document.querySelector('header h1'); |
2898 | | - |
2899 | | - if (paywall) { |
2900 | | - createLink(article_title); |
2901 | | - } |
2902 | | - |
2903 | | - // Lien Europresse dans la modale, au chargement |
2904 | 2910 | const callback = (mutationList, observer) => { |
2905 | 2911 | for (const mutation of mutationList) { |
2906 | 2912 | if (mutation.type === 'childList') { |
2907 | 2913 | for (let node of mutation.addedNodes) { |
2908 | | - const paywall_modal = document.querySelector('.cj-root'); |
| 2914 | + const paywall_modal = document.querySelector('.PSAPAG_root'); |
2909 | 2915 | if (paywall_modal) { |
2910 | | - const subscriptionForm = document.querySelector('[data-current-screen="StopEmailIdentification"] form'); |
2911 | | - createLink(subscriptionForm); |
| 2916 | + ; |
| 2917 | + const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot; |
| 2918 | + const modal_content = shadow_content.firstChild.lastChild; |
| 2919 | + createLink(article_title); |
| 2920 | + createLink(modal_content); |
| 2921 | + |
2912 | 2922 | buttonAdded = true; |
2913 | | - subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link'); |
2914 | 2923 | observer.disconnect(); |
2915 | 2924 | } |
2916 | 2925 | } |
|
2939 | 2948 | text-align: center; |
2940 | 2949 | text-decoration: none; |
2941 | 2950 | } |
2942 | | - |
2943 | | - .ophirofox-modal-link { |
2944 | | - display: block; |
2945 | | - margin-top: 0; |
2946 | | - padding: 0.5rem; |
2947 | | - border-radius: 0; |
2948 | | - } |
2949 | 2951 | `); |
2950 | 2952 | } |
2951 | 2953 |
|
2952 | 2954 | if ("https://www.nieuwsblad.be/*".includes(hostname)) { |
2953 | 2955 |
|
2954 | 2956 | window.addEventListener("load", function(event) { |
| 2957 | + let buttonAdded = false; |
| 2958 | + const article_title = document.querySelector('header[data-testid="article-header"] h1'); |
| 2959 | + |
2955 | 2960 | function extractKeywords() { |
2956 | | - return document.querySelector("header h1").textContent; |
| 2961 | + return article_title.textContent; |
2957 | 2962 | } |
2958 | 2963 |
|
2959 | | - let buttonAdded = false; |
2960 | | - |
2961 | 2964 | async function createLink(elt) { |
2962 | 2965 | if (elt && buttonAdded == false) { |
2963 | 2966 | const a = await ophirofoxEuropresseLink(extractKeywords()); |
2964 | 2967 | elt.after(a); |
| 2968 | + console.log(elt); |
| 2969 | + if (elt !== article_title) { |
| 2970 | + //second link is in shadow dom context -> no access to stylesheet |
| 2971 | + a.style.display = "block" |
| 2972 | + a.style.width = "35%"; |
| 2973 | + a.style.margin = "0.5rem auto"; |
| 2974 | + a.style.padding = "0.5rem 0"; |
| 2975 | + a.style.borderRadius = "0.3rem"; |
| 2976 | + a.style.backgroundColor = "#ffc700"; |
| 2977 | + a.style.color = "#000"; |
| 2978 | + a.style.textDecoration = "none"; |
| 2979 | + a.style.textAlign = "center"; |
| 2980 | + } |
2965 | 2981 | } |
2966 | 2982 | } |
2967 | 2983 |
|
2968 | 2984 | async function onLoad() { |
2969 | | - // Lien Europresse dans le corps de l'article |
2970 | | - const paywall = document.querySelector('[data-cj-root="subscription-wall"]'); |
2971 | | - const article_title = document.querySelector('header h1'); |
2972 | | - |
2973 | | - if (paywall) { |
2974 | | - createLink(article_title); |
2975 | | - } |
2976 | | - |
2977 | | - // Lien Europresse dans la modale, au chargement |
2978 | 2985 | const callback = (mutationList, observer) => { |
2979 | 2986 | for (const mutation of mutationList) { |
2980 | 2987 | if (mutation.type === 'childList') { |
2981 | 2988 | for (let node of mutation.addedNodes) { |
2982 | | - const paywall_modal = document.querySelector('.cj-root'); |
| 2989 | + const paywall_modal = document.querySelector('.PSAPAG_root'); |
2983 | 2990 | if (paywall_modal) { |
2984 | | - const subscriptionForm = document.querySelector('[data-current-screen="StopEmailIdentification"] form'); |
2985 | | - createLink(subscriptionForm); |
| 2991 | + ; |
| 2992 | + const shadow_content = document.querySelector('.PSAPAG_root').shadowRoot; |
| 2993 | + const modal_content = shadow_content.firstChild.lastChild; |
| 2994 | + createLink(article_title); |
| 2995 | + createLink(modal_content); |
| 2996 | + |
2986 | 2997 | buttonAdded = true; |
2987 | | - subscriptionForm.nextElementSibling.classList.add('ophirofox-modal-link'); |
2988 | 2998 | observer.disconnect(); |
2989 | 2999 | } |
2990 | 3000 | } |
|
3013 | 3023 | text-align: center; |
3014 | 3024 | text-decoration: none; |
3015 | 3025 | } |
3016 | | - |
3017 | | - .ophirofox-modal-link { |
3018 | | - display: block; |
3019 | | - margin-top: 0; |
3020 | | - padding: 0.5rem; |
3021 | | - border-radius: 0; |
3022 | | - } |
3023 | 3026 | `); |
3024 | 3027 | } |
3025 | 3028 |
|
|
0 commit comments