|
1 | 1 | // ==UserScript== |
2 | | -// @version 2.6.815.112 |
| 2 | +// @version 2.6.815.1917 |
3 | 3 | // @author Write |
4 | 4 | // @name OphirofoxScript |
5 | 5 | // @grant GM.getValue |
|
1922 | 1922 | (elem) => elem.textContent == "Se connecter" |
1923 | 1923 | ); |
1924 | 1924 |
|
1925 | | - let articlePath = ''; |
| 1925 | + let articlePath; |
1926 | 1926 | await chrome.storage.sync.get(['ophirofox_mediapart_article']).then((result) => { |
1927 | 1927 | articlePath = result.ophirofox_mediapart_article |
1928 | 1928 | }) |
1929 | 1929 |
|
1930 | 1930 | let currentPage = new URL(window.location) |
| 1931 | + let isRedirectArticle = articlePath && currentPage.pathname != articlePath |
1931 | 1932 | if (isNotConnected) { |
1932 | 1933 | console.error("ophirofox login failed") |
1933 | 1934 | return |
1934 | | - } else if (currentPage.pathname != articlePath) { |
| 1935 | + } else if (isRedirectArticle) { |
1935 | 1936 | //redirect to mirror article |
1936 | 1937 | window.location.pathname = articlePath |
| 1938 | + //clear storage to enable futur navigation on the mirror |
| 1939 | + chrome.storage.sync.remove(["ophirofox_mediapart_article"]) |
1937 | 1940 | } |
1938 | 1941 | } |
1939 | 1942 |
|
|
2020 | 2023 | (elem) => elem.textContent == "Se connecter" |
2021 | 2024 | ); |
2022 | 2025 |
|
2023 | | - let articlePath = ''; |
| 2026 | + let articlePath; |
2024 | 2027 | await chrome.storage.sync.get(['ophirofox_mediapart_article']).then((result) => { |
2025 | 2028 | articlePath = result.ophirofox_mediapart_article |
2026 | 2029 | }) |
2027 | 2030 |
|
2028 | 2031 | let currentPage = new URL(window.location) |
| 2032 | + let isRedirectArticle = articlePath && currentPage.pathname != articlePath |
2029 | 2033 | if (isNotConnected) { |
2030 | 2034 | console.error("ophirofox login failed") |
2031 | 2035 | return |
2032 | | - } else if (currentPage.pathname != articlePath) { |
| 2036 | + } else if (isRedirectArticle) { |
2033 | 2037 | //redirect to mirror article |
2034 | 2038 | window.location.pathname = articlePath |
| 2039 | + //clear storage to enable futur navigation on the mirror |
| 2040 | + chrome.storage.sync.remove(["ophirofox_mediapart_article"]) |
2035 | 2041 | } |
2036 | 2042 | } |
2037 | 2043 |
|
|
2118 | 2124 | (elem) => elem.textContent == "Se connecter" |
2119 | 2125 | ); |
2120 | 2126 |
|
2121 | | - let articlePath = ''; |
| 2127 | + let articlePath; |
2122 | 2128 | await chrome.storage.sync.get(['ophirofox_mediapart_article']).then((result) => { |
2123 | 2129 | articlePath = result.ophirofox_mediapart_article |
2124 | 2130 | }) |
2125 | 2131 |
|
2126 | 2132 | let currentPage = new URL(window.location) |
| 2133 | + let isRedirectArticle = articlePath && currentPage.pathname != articlePath |
2127 | 2134 | if (isNotConnected) { |
2128 | 2135 | console.error("ophirofox login failed") |
2129 | 2136 | return |
2130 | | - } else if (currentPage.pathname != articlePath) { |
| 2137 | + } else if (isRedirectArticle) { |
2131 | 2138 | //redirect to mirror article |
2132 | 2139 | window.location.pathname = articlePath |
| 2140 | + //clear storage to enable futur navigation on the mirror |
| 2141 | + chrome.storage.sync.remove(["ophirofox_mediapart_article"]) |
2133 | 2142 | } |
2134 | 2143 | } |
2135 | 2144 |
|
|
0 commit comments