Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Tokopedia Hardcore Pre-Load URL Cleaner
- // @namespace http://tampermonkey.net/
- // @version 1.4
- // @description Force early redirect to clean Tokopedia search URLs before any frontend code runs. Fixes SPA hijacking issues. Uses inline injection to bypass Tampermonkey delay.
- // @author You
- // @match https://www.tokopedia.com/*
- // @run-at document-start
- // ==/UserScript==
- (function () {
- const junkParams = [
- 'minus_ids',
- 'search_id',
- 'has_more',
- 'next_offset_organic',
- 'next_offset_organic_ad',
- 'navsource',
- 'srp_component_id',
- 'srp_page_id',
- 'srp_page_title',
- 'st',
- '_sort',
- '_useSearchResultTracking'
- ];
- const scriptContent = `
- (function() {
- const url = new URL(window.location.href);
- const params = url.searchParams;
- let changed = false;
- const junk = ${JSON.stringify(junkParams)};
- junk.forEach(p => {
- if (params.has(p)) {
- params.delete(p);
- changed = true;
- }
- });
- if (changed) {
- const cleaned = \`\${url.origin}\${url.pathname}?\${params.toString()}\`;
- window.location.replace(cleaned);
- }
- })();
- `;
- const script = document.createElement('script');
- script.textContent = scriptContent;
- document.documentElement.prepend(script);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement