SurferSEO Image Button

Adds a button to open the image upload dialog on SurferSEO page

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         SurferSEO Image Button
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Adds a button to open the image upload dialog on SurferSEO page
// @author       mhshan
// @match        https://app.surferseo.com/drafts/s/*
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to handle Image button click
    function handleImageClick() {
        const targetDiv = document.querySelector('div[data-testid="ribbon-image-button"]');
        if (targetDiv) {
            targetDiv.click();
        } else {
            alert('Target element not found.');
        }
    }

    // Check if the URL matches the pattern
    if (window.location.href.startsWith('https://app.surferseo.com/drafts/s/')) {
        const button = document.createElement('button');
        button.innerText = 'Image';
        button.style.position = 'fixed';
        button.style.top = '500px';
        button.style.left = '60px';
        button.style.height = '40px';
        button.style.width = '150px';
        button.style.background = 'Black';
        button.style.color = 'white';
        button.style.fontWeight = '600';
        button.style.zIndex = 1000;
        button.style.borderRadius = '8px';
        button.style.padding = '5px 10px';
        button.style.border = 'none';
        button.style.cursor = 'pointer';
        button.style.transition = 'background 0.3s ease, transform 0.3s ease';

        button.addEventListener('mouseover', function() {
            button.style.background = '#3CCF4E';
            button.style.transform = 'scale(1.05)';
        });

        button.addEventListener('mouseout', function() {
            button.style.background = 'Black';
            button.style.transform = 'scale(1)';
        });

        button.addEventListener('click', handleImageClick);

        document.body.appendChild(button);
    }
})();