您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Always apply the vegan filter on tesco.com
- // ==UserScript==
- // @name TescoVegan
- // @author Ivy9217
- // @version 1.0.6
- // @description Always apply the vegan filter on tesco.com
- // @match https://www.tesco.com/groceries/*
- // @exclude /https://www.tesco.com/groceries/en-GB/(products|trolley|slots|orders).*/
- // @connect tesco.com
- // @run-at document-end
- // @namespace https://greasyfork.org/users/982144
- // @license MIT
- // ==/UserScript==
- // Content on the same page changes dynamically.
- // It's not enough to change the page URL after load, we must use this instead
- function observeDOM(callback) {
- var mutationObserver = new MutationObserver(function(mutations) {
- mutations.forEach(function(mutation) {
- callback(mutation)
- });
- });
- mutationObserver.observe(document.body, {
- attributes: true,
- childList: true,
- subtree: true,
- attributeFilter: ["class"]
- });
- }
- function appendUrlParameters(mutation) {
- var oldUrl = window.location.search;
- // Check if the filter is already applied
- if (!/dietary=Vegan/.test(oldUrl)) {
- var newURL = window.location.protocol + "//" +
- window.location.host +
- window.location.pathname + "?dietary=Vegan&viewAll=dietary" +
- window.location.search.replace('?', '&') +
- window.location.hash;
- window.location.replace(newURL);
- }
- }
- function run() {
- observeDOM(appendUrlParameters);
- }
- setTimeout(run, 1000);