| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- window.busying = false
- // 处理 AngularJS 集成
- function handleAngularJS(select) {
- try {
- const scope = angular.element(select).scope();
- if (scope && scope.$apply) {
- scope.$apply(function() {
- // 确保 AngularJS 知道变化
- const modelName = select.getAttribute('ng-model');
- if (modelName) {
- scope[modelName] = select.value;
- }
- });
- }
- } catch (error) {
- console.log('AngularJS 处理失败(可忽略):', error);
- }
- }
- function triggerChangeEvents(select) {
- const events = ['input', 'change', 'blur'];
- events.forEach(eventType => {
- const event = new Event(eventType, { bubbles: true });
- select.dispatchEvent(event);
- });
- }
- function selectThirdOrString3(selectorStr) {
- const select = document.querySelector('.selectpicker');
- if (!select) return false;
-
- // 首先尝试选择值为 "string:3號" 的选项
- for (let i = 0; i < select.options.length; i++) {
- if (select.options[i].value.includes(selectorStr)) {
- select.selectedIndex = i;
- triggerChangeEvents(select);
- handleAngularJS(select);
- console.log('已选择: ' + selectorStr);
- return true;
- }
- }
-
- console.log('未找到匹配的选项');
- return false;
- }
- setInterval(() => {
- if (!window.busying) {
- if (location.href.includes('https://www.goopi.co/products/')) {
- document.title = '运行中!'
- // 先判断 货号
- selectThirdOrString3('string:3號');
- if (document.querySelector('#btn-main-checkout')) {
- window.busying = true
- document.title = '跳转中!'
- setTimeout(() => {
- location.href="https://www.goopi.co/checkout"
- }, 1000);
- }
- if (document.querySelector('[ng-if="!isItemInBackInStock"]')) {
- window.busying = true
- setTimeout(() => {
- window.busying = false
- location.reload()
- }, 3000);
- }
- }
- if (location.href.includes('https://www.goopi.co/cart')) {
- document.title = '结账中!'
- window.busying = true
- if (document.querySelector('.btn-checkout')) {
- document.querySelector('.btn-checkout').click()
- }
- }
- }
- }, 1000);
|